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/05/22 21:37:10 UTC

svn commit: r1890122 [6/16] - in /poi/trunk/poi-scratchpad/src: main/java/org/apache/poi/hdgf/ main/java/org/apache/poi/hdgf/chunks/ main/java/org/apache/poi/hdgf/dev/ main/java/org/apache/poi/hdgf/exceptions/ main/java/org/apache/poi/hdgf/extractor/ m...

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PersistPtrHolder.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PersistPtrHolder.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PersistPtrHolder.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PersistPtrHolder.java Sat May 22 21:37:08 2021
@@ -48,22 +48,22 @@ import org.apache.poi.util.LittleEndianC
 public final class PersistPtrHolder extends PositionDependentRecordAtom
 {
 
-	//arbitrarily selected; may need to increase
-	private static final int MAX_RECORD_LENGTH = 100_000;
+    //arbitrarily selected; may need to increase
+    private static final int MAX_RECORD_LENGTH = 100_000;
 
-	private final byte[] _header;
-	private byte[] _ptrData; // Will need to update this once we allow updates to _slideLocations
-	private final long _type;
-
-	/**
-	 * Holds the lookup for slides to their position on disk.
-	 * You always need to check the most recent PersistPtrHolder
-	 *  that knows about a given slide to find the right location
-	 */
-	private final Map<Integer,Integer> _slideLocations;
+    private final byte[] _header;
+    private byte[] _ptrData; // Will need to update this once we allow updates to _slideLocations
+    private final long _type;
 
-	private static final BitField persistIdFld = BitFieldFactory.getInstance(0X000FFFFF);
-	private static final BitField cntPersistFld  = BitFieldFactory.getInstance(0XFFF00000);
+    /**
+     * Holds the lookup for slides to their position on disk.
+     * You always need to check the most recent PersistPtrHolder
+     *  that knows about a given slide to find the right location
+     */
+    private final Map<Integer,Integer> _slideLocations;
+
+    private static final BitField persistIdFld = BitFieldFactory.getInstance(0X000FFFFF);
+    private static final BitField cntPersistFld  = BitFieldFactory.getInstance(0XFFF00000);
 
     /**
      * Return the value we were given at creation, be it 6001 or 6002
@@ -71,74 +71,74 @@ public final class PersistPtrHolder exte
     @Override
     public long getRecordType() { return _type; }
 
-	/**
-	 * Get the list of slides that this PersistPtrHolder knows about.
-	 * (They will be the keys in the map for looking up the positions
-	 *  of these slides)
-	 */
-	public int[] getKnownSlideIDs() {
-		int[] ids = new int[_slideLocations.size()];
-		int i = 0;
-		for (Integer slideId : _slideLocations.keySet()) {
-		    ids[i++] = slideId;
-		}
-		return ids;
-	}
-
-	/**
-	 * Get the lookup from slide numbers to byte offsets, for the slides
-	 *  known about by this PersistPtrHolder.
-	 */
-	public Map<Integer,Integer> getSlideLocationsLookup() {
-		return Collections.unmodifiableMap(_slideLocations);
-	}
-
-	/**
-	 * Create a new holder for a PersistPtr record
-	 */
-	protected PersistPtrHolder(byte[] source, int start, int len) {
-		// Sanity Checking - including whole header, so treat
-		//  length as based of 0, not 8 (including header size based)
-		if(len < 8) { len = 8; }
-
-		// Treat as an atom, grab and hold everything
-		_header = Arrays.copyOfRange(source, start, start+8);
-		_type = LittleEndian.getUShort(_header,2);
-
-		// Try to make sense of the data part:
-		// Data part is made up of a number of these sets:
-		//   32 bit info value
-		//		12 bits count of # of entries
-		//      base number for these entries
-		//   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);
-
-		int pos = 0;
-		while(pos < _ptrData.length) {
-		    // Grab the info field
-			int info = LittleEndian.getInt(_ptrData,pos);
+    /**
+     * Get the list of slides that this PersistPtrHolder knows about.
+     * (They will be the keys in the map for looking up the positions
+     *  of these slides)
+     */
+    public int[] getKnownSlideIDs() {
+        int[] ids = new int[_slideLocations.size()];
+        int i = 0;
+        for (Integer slideId : _slideLocations.keySet()) {
+            ids[i++] = slideId;
+        }
+        return ids;
+    }
+
+    /**
+     * Get the lookup from slide numbers to byte offsets, for the slides
+     *  known about by this PersistPtrHolder.
+     */
+    public Map<Integer,Integer> getSlideLocationsLookup() {
+        return Collections.unmodifiableMap(_slideLocations);
+    }
+
+    /**
+     * Create a new holder for a PersistPtr record
+     */
+    protected PersistPtrHolder(byte[] source, int start, int len) {
+        // Sanity Checking - including whole header, so treat
+        //  length as based of 0, not 8 (including header size based)
+        if(len < 8) { len = 8; }
+
+        // Treat as an atom, grab and hold everything
+        _header = Arrays.copyOfRange(source, start, start+8);
+        _type = LittleEndian.getUShort(_header,2);
+
+        // Try to make sense of the data part:
+        // Data part is made up of a number of these sets:
+        //   32 bit info value
+        //      12 bits count of # of entries
+        //      base number for these entries
+        //   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);
+
+        int pos = 0;
+        while(pos < _ptrData.length) {
+            // Grab the info field
+            int info = LittleEndian.getInt(_ptrData,pos);
 
-			// First 20 bits = offset number
-			// Remaining 12 bits = offset count
+            // First 20 bits = offset number
+            // Remaining 12 bits = offset count
             int offset_no = persistIdFld.getValue(info);
-			int offset_count = cntPersistFld.getValue(info);
+            int offset_count = cntPersistFld.getValue(info);
+
+            // Wind on by the 4 byte info header
+            pos += 4;
 
-			// Wind on by the 4 byte info header
-			pos += 4;
+            // Grab the offsets for each of the sheets
+            for(int i=0; i<offset_count; i++) {
+                int sheet_no = offset_no + i;
+                int sheet_offset = (int)LittleEndian.getUInt(_ptrData,pos);
+                _slideLocations.put(sheet_no, sheet_offset);
 
-			// Grab the offsets for each of the sheets
-			for(int i=0; i<offset_count; i++) {
-				int sheet_no = offset_no + i;
-				int sheet_offset = (int)LittleEndian.getUInt(_ptrData,pos);
-				_slideLocations.put(sheet_no, sheet_offset);
-
-				// Wind on by 4 bytes per sheet found
-				pos += 4;
-			}
-		}
-	}
+                // Wind on by 4 bytes per sheet found
+                pos += 4;
+            }
+        }
+    }
 
     /**
      *  remove all slide references
@@ -160,88 +160,88 @@ public final class PersistPtrHolder exte
         _slideLocations.put(slideID, posOnDisk);
     }
 
-	/**
-	 * At write-out time, update the references to the sheets to their
-	 *  new positions
-	 */
-	@Override
-	public void updateOtherRecordReferences(Map<Integer,Integer> oldToNewReferencesLookup) {
-		// Loop over all the slides we know about
-		// Find where they used to live, and where they now live
-	    for (Entry<Integer,Integer> me : _slideLocations.entrySet()) {
-	        Integer oldPos = me.getValue();
-	        Integer newPos = oldToNewReferencesLookup.get(oldPos);
+    /**
+     * At write-out time, update the references to the sheets to their
+     *  new positions
+     */
+    @Override
+    public void updateOtherRecordReferences(Map<Integer,Integer> oldToNewReferencesLookup) {
+        // Loop over all the slides we know about
+        // Find where they used to live, and where they now live
+        for (Entry<Integer,Integer> me : _slideLocations.entrySet()) {
+            Integer oldPos = me.getValue();
+            Integer newPos = oldToNewReferencesLookup.get(oldPos);
 
             if (newPos == null) {
                 Integer id = me.getKey();
-				LOG.atWarn().log("Couldn't find the new location of the \"slide\" with id {} that used to " +
-						"be at {}. Not updating the position of it, you probably won't be able to find it any more " +
-						"(if you ever could!)", id, oldPos);
+                LOG.atWarn().log("Couldn't find the new location of the \"slide\" with id {} that used to " +
+                        "be at {}. Not updating the position of it, you probably won't be able to find it any more " +
+                        "(if you ever could!)", id, oldPos);
             } else {
                 me.setValue(newPos);
             }
-	    }
-	}
+        }
+    }
+
+    private void normalizePersistDirectory() {
+        // Building the info block
+        // First 20 bits = offset number = slide ID (persistIdFld, i.e. first slide ID of a continuous group)
+        // Remaining 12 bits = offset count = 1 (cntPersistFld, i.e. continuous entries in a group)
+        //
+        // the info block is then followed by the slide offset (32 bits)
+
+        int[] infoBlocks = new int[_slideLocations.size()*2];
+        int lastSlideId = -1;
+        int lastPersistIdx = 0;
+        int lastIdx = -1;
+        int entryCnt = 0;
+        int baseSlideId = -1;
+
+        Iterable<Entry<Integer,Integer>> iter = _slideLocations.entrySet().stream()
+            .sorted(Comparator.comparingInt(Entry::getKey))::iterator;
+        for (Entry<Integer, Integer> me : iter) {
+            int nextSlideId = me.getKey();
+            if (lastSlideId + 1 < nextSlideId) {
+                // start new PersistDirectoryEntry
+                lastPersistIdx = ++lastIdx;
+                entryCnt = 0;
+                baseSlideId = nextSlideId;
+            }
+
+            int infoBlock = persistIdFld.setValue(0, baseSlideId);
+            infoBlock = cntPersistFld.setValue(infoBlock, ++entryCnt);
+            infoBlocks[lastPersistIdx] = infoBlock;
+            // add the offset
+            infoBlocks[++lastIdx] = me.getValue();
+
+            lastSlideId = nextSlideId;
+        }
+
+        // Save the new ptr data
+        _ptrData = new byte[(lastIdx+1)*LittleEndianConsts.INT_SIZE];
+        for (int idx = 0; idx<=lastIdx; idx++) {
+            LittleEndian.putInt(_ptrData, idx*LittleEndianConsts.INT_SIZE, infoBlocks[idx]);
+        }
 
-	private void normalizePersistDirectory() {
-		// Building the info block
-		// First 20 bits = offset number = slide ID (persistIdFld, i.e. first slide ID of a continuous group)
-		// Remaining 12 bits = offset count = 1 (cntPersistFld, i.e. continuous entries in a group)
-		//
-		// the info block is then followed by the slide offset (32 bits)
-
-		int[] infoBlocks = new int[_slideLocations.size()*2];
-		int lastSlideId = -1;
-		int lastPersistIdx = 0;
-		int lastIdx = -1;
-		int entryCnt = 0;
-		int baseSlideId = -1;
-
-		Iterable<Entry<Integer,Integer>> iter = _slideLocations.entrySet().stream()
-			.sorted(Comparator.comparingInt(Entry::getKey))::iterator;
-		for (Entry<Integer, Integer> me : iter) {
-			int nextSlideId = me.getKey();
-			if (lastSlideId + 1 < nextSlideId) {
-				// start new PersistDirectoryEntry
-				lastPersistIdx = ++lastIdx;
-				entryCnt = 0;
-				baseSlideId = nextSlideId;
-			}
-
-			int infoBlock = persistIdFld.setValue(0, baseSlideId);
-			infoBlock = cntPersistFld.setValue(infoBlock, ++entryCnt);
-			infoBlocks[lastPersistIdx] = infoBlock;
-			// add the offset
-			infoBlocks[++lastIdx] = me.getValue();
-
-			lastSlideId = nextSlideId;
-		}
-
-		// Save the new ptr data
-		_ptrData = new byte[(lastIdx+1)*LittleEndianConsts.INT_SIZE];
-		for (int idx = 0; idx<=lastIdx; idx++) {
-			LittleEndian.putInt(_ptrData, idx*LittleEndianConsts.INT_SIZE, infoBlocks[idx]);
-		}
-
-		// Update the atom header
-		LittleEndian.putInt(_header, 4, _ptrData.length);
-	}
-
-	/**
-	 * Write the contents of the record back, so it can be written
-	 *  to disk
-	 */
-	@Override
+        // Update the atom header
+        LittleEndian.putInt(_header, 4, _ptrData.length);
+    }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     *  to disk
+     */
+    @Override
     public void writeOut(OutputStream out) throws IOException {
-	    normalizePersistDirectory();
-		out.write(_header);
-		out.write(_ptrData);
-	}
-
-	@Override
-	public Map<String, Supplier<?>> getGenericProperties() {
-		return GenericRecordUtil.getGenericProperties(
-			"slideLocations", this::getSlideLocationsLookup
-		);
-	}
+        normalizePersistDirectory();
+        out.write(_header);
+        out.write(_ptrData);
+    }
+
+    @Override
+    public Map<String, Supplier<?>> getGenericProperties() {
+        return GenericRecordUtil.getGenericProperties(
+            "slideLocations", this::getSlideLocationsLookup
+        );
+    }
 }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PositionDependentRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PositionDependentRecord.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PositionDependentRecord.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PositionDependentRecord.java Sat May 22 21:37:08 2021
@@ -32,18 +32,18 @@ import java.util.Map;
 
 public interface PositionDependentRecord
 {
-	/** Fetch our location on the disk, as of the last write out */
-	public int getLastOnDiskOffset();
+    /** Fetch our location on the disk, as of the last write out */
+    public int getLastOnDiskOffset();
 
-	/**
-	 * Update the Record's idea of where on disk it lives, after a write out.
-	 * Use with care...
-	 */
-	public void setLastOnDiskOffset(int offset);
+    /**
+     * Update the Record's idea of where on disk it lives, after a write out.
+     * Use with care...
+     */
+    public void setLastOnDiskOffset(int offset);
 
-	/**
-	 * Offer the record the list of records that have changed their
-	 *  location as part of the writeout.
-	 */
-	public void updateOtherRecordReferences(Map<Integer,Integer> oldToNewReferencesLookup);
+    /**
+     * Offer the record the list of records that have changed their
+     *  location as part of the writeout.
+     */
+    public void updateOtherRecordReferences(Map<Integer,Integer> oldToNewReferencesLookup);
 }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PositionDependentRecordAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PositionDependentRecordAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PositionDependentRecordAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PositionDependentRecordAtom.java Sat May 22 21:37:08 2021
@@ -26,25 +26,25 @@ import java.util.Map;
 
 public abstract class PositionDependentRecordAtom extends RecordAtom implements PositionDependentRecord
 {
-	/** Our location on the disk, as of the last write out */
-	private int myLastOnDiskOffset;
+    /** Our location on the disk, as of the last write out */
+    private int myLastOnDiskOffset;
 
-	/** Fetch our location on the disk, as of the last write out */
-	public int getLastOnDiskOffset() { return myLastOnDiskOffset; }
+    /** Fetch our location on the disk, as of the last write out */
+    public int getLastOnDiskOffset() { return myLastOnDiskOffset; }
 
-	/**
-	 * Update the Record's idea of where on disk it lives, after a write out.
-	 * Use with care...
-	 */
-	public void setLastOnDiskOffset(int offset) {
-		myLastOnDiskOffset = offset;
-	}
+    /**
+     * Update the Record's idea of where on disk it lives, after a write out.
+     * Use with care...
+     */
+    public void setLastOnDiskOffset(int offset) {
+        myLastOnDiskOffset = offset;
+    }
 
-	/**
-	 * Offer the record the list of records that have changed their
-	 *  location as part of the writeout.
-	 * Allows records to update their internal pointers to other records
-	 *  locations
-	 */
-	public abstract void updateOtherRecordReferences(Map<Integer,Integer> oldToNewReferencesLookup);
+    /**
+     * Offer the record the list of records that have changed their
+     *  location as part of the writeout.
+     * Allows records to update their internal pointers to other records
+     *  locations
+     */
+    public abstract void updateOtherRecordReferences(Map<Integer,Integer> oldToNewReferencesLookup);
 }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PositionDependentRecordContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PositionDependentRecordContainer.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PositionDependentRecordContainer.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PositionDependentRecordContainer.java Sat May 22 21:37:08 2021
@@ -26,38 +26,38 @@ import java.util.Map;
 
 public abstract class PositionDependentRecordContainer extends RecordContainer implements PositionDependentRecord
 {
-	private int sheetId; // Found from PersistPtrHolder
+    private int sheetId; // Found from PersistPtrHolder
 
-	/**
-	 * Fetch our sheet ID, as found from a PersistPtrHolder.
-	 * Should match the RefId of our matching SlidePersistAtom
-	 */
-	public int getSheetId() { return sheetId; }
-
-	/**
-	 * Set our sheet ID, as found from a PersistPtrHolder
-	 */
-	public void setSheetId(int id) { sheetId = id; }
-
-
-	/** Our location on the disk, as of the last write out */
-	private int myLastOnDiskOffset;
-
-	/** Fetch our location on the disk, as of the last write out */
-	public int getLastOnDiskOffset() { return myLastOnDiskOffset; }
-
-	/**
-	 * Update the Record's idea of where on disk it lives, after a write out.
-	 * Use with care...
-	 */
-	public void setLastOnDiskOffset(int offset) {
-		myLastOnDiskOffset = offset;
-	}
-
-	/**
-	 * Since we're a container, we don't mind if other records move about.
-	 * If we're told they have, just return straight off.
-	 */
-	public void updateOtherRecordReferences(Map<Integer,Integer> oldToNewReferencesLookup) {
-	}
+    /**
+     * Fetch our sheet ID, as found from a PersistPtrHolder.
+     * Should match the RefId of our matching SlidePersistAtom
+     */
+    public int getSheetId() { return sheetId; }
+
+    /**
+     * Set our sheet ID, as found from a PersistPtrHolder
+     */
+    public void setSheetId(int id) { sheetId = id; }
+
+
+    /** Our location on the disk, as of the last write out */
+    private int myLastOnDiskOffset;
+
+    /** Fetch our location on the disk, as of the last write out */
+    public int getLastOnDiskOffset() { return myLastOnDiskOffset; }
+
+    /**
+     * Update the Record's idea of where on disk it lives, after a write out.
+     * Use with care...
+     */
+    public void setLastOnDiskOffset(int offset) {
+        myLastOnDiskOffset = offset;
+    }
+
+    /**
+     * Since we're a container, we don't mind if other records move about.
+     * If we're told they have, just return straight off.
+     */
+    public void updateOtherRecordReferences(Map<Integer,Integer> oldToNewReferencesLookup) {
+    }
 }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Record.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Record.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Record.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Record.java Sat May 22 21:37:08 2021
@@ -43,169 +43,169 @@ import static org.apache.logging.log4j.u
 public abstract class Record implements GenericRecord
 {
     // For logging
-	protected static final Logger LOG = LogManager.getLogger(Record.class);
+    protected static final Logger LOG = LogManager.getLogger(Record.class);
 
-	/**
-	 * Is this record type an Atom record (only has data),
-	 *  or is it a non-Atom record (has other records)?
-	 */
-	public abstract boolean isAnAtom();
-
-	/**
-	 * Returns the type (held as a little endian in bytes 3 and 4)
-	 *  that this class handles
-	 */
-	public abstract long getRecordType();
-
-	/**
-	 * Fetch all the child records of this record
-	 * If this record is an atom, will return null
-	 * If this record is a non-atom, but has no children, will return
-	 *  an empty array
-	 */
-	public abstract Record[] getChildRecords();
-
-	/**
-	 * Have the contents printer out into an OutputStream, used when
-	 *  writing a file back out to disk
-	 * (Normally, atom classes will keep their bytes around, but
-	 *  non atom classes will just request the bytes from their
-	 *  children, then chuck on their header and return)
-	 */
-	public abstract void writeOut(OutputStream o) throws IOException;
-
-	@Override
-	public Enum getGenericRecordType() {
-		return RecordTypes.forTypeID((int)getRecordType());
-	}
-
-	@Override
-	public List<Record> getGenericChildren() {
-		Record[] recs = getChildRecords();
-		return (recs == null) ? null : Arrays.asList(recs);
-	}
-
-	/**
-	 * When writing out, write out a signed int (32bit) in Little Endian format
-	 */
-	public static void writeLittleEndian(int i,OutputStream o) throws IOException {
-		byte[] bi = new byte[4];
-		LittleEndian.putInt(bi,0,i);
-		o.write(bi);
-	}
-	/**
-	 * When writing out, write out a signed short (16bit) in Little Endian format
-	 */
-	public static void writeLittleEndian(short s,OutputStream o) throws IOException {
-		byte[] bs = new byte[2];
-		LittleEndian.putShort(bs,0,s);
-		o.write(bs);
-	}
-
-	/**
-	 * Build and return the Record at the given offset.
-	 * Note - does less error checking and handling than findChildRecords
-	 * @param b The byte array to build from
-	 * @param offset The offset to build at
-	 */
-	public static Record buildRecordAtOffset(byte[] b, int offset) {
-		long type = LittleEndian.getUShort(b,offset+2);
-		long rlen = LittleEndian.getUInt(b,offset+4);
-
-		// Sanity check the length
-		int rleni = (int)rlen;
-		if(rleni < 0) { rleni = 0; }
-
-		return createRecordForType(type,b,offset,8+rleni);
-	}
-
-	/**
-	 * Default method for finding child records of a container record
-	 */
-	public static Record[] findChildRecords(byte[] b, int start, int len) {
-		List<Record> children = new ArrayList<>(5);
-
-		// Jump our little way along, creating records as we go
-		int pos = start;
-		while(pos <= (start+len-8)) {
-			long type = LittleEndian.getUShort(b,pos+2);
-			long rlen = LittleEndian.getUInt(b,pos+4);
-
-			// Sanity check the length
-			int rleni = (int)rlen;
-			if(rleni < 0) { rleni = 0; }
-
-			// Abort if first record is of type 0000 and length FFFF,
-			//  as that's a sign of a screwed up record
-			if(pos == 0 && type == 0L && rleni == 0xffff) {
-				throw new CorruptPowerPointFileException("Corrupt document - starts with record of type 0000 and length 0xFFFF");
-			}
-
-			Record r = createRecordForType(type,b,pos,8+rleni);
-			if(r != null) {
-				children.add(r);
-			}
-			pos += 8;
-			pos += rleni;
-		}
+    /**
+     * Is this record type an Atom record (only has data),
+     *  or is it a non-Atom record (has other records)?
+     */
+    public abstract boolean isAnAtom();
+
+    /**
+     * Returns the type (held as a little endian in bytes 3 and 4)
+     *  that this class handles
+     */
+    public abstract long getRecordType();
+
+    /**
+     * Fetch all the child records of this record
+     * If this record is an atom, will return null
+     * If this record is a non-atom, but has no children, will return
+     *  an empty array
+     */
+    public abstract Record[] getChildRecords();
+
+    /**
+     * Have the contents printer out into an OutputStream, used when
+     *  writing a file back out to disk
+     * (Normally, atom classes will keep their bytes around, but
+     *  non atom classes will just request the bytes from their
+     *  children, then chuck on their header and return)
+     */
+    public abstract void writeOut(OutputStream o) throws IOException;
+
+    @Override
+    public Enum getGenericRecordType() {
+        return RecordTypes.forTypeID((int)getRecordType());
+    }
+
+    @Override
+    public List<Record> getGenericChildren() {
+        Record[] recs = getChildRecords();
+        return (recs == null) ? null : Arrays.asList(recs);
+    }
+
+    /**
+     * When writing out, write out a signed int (32bit) in Little Endian format
+     */
+    public static void writeLittleEndian(int i,OutputStream o) throws IOException {
+        byte[] bi = new byte[4];
+        LittleEndian.putInt(bi,0,i);
+        o.write(bi);
+    }
+    /**
+     * When writing out, write out a signed short (16bit) in Little Endian format
+     */
+    public static void writeLittleEndian(short s,OutputStream o) throws IOException {
+        byte[] bs = new byte[2];
+        LittleEndian.putShort(bs,0,s);
+        o.write(bs);
+    }
+
+    /**
+     * Build and return the Record at the given offset.
+     * Note - does less error checking and handling than findChildRecords
+     * @param b The byte array to build from
+     * @param offset The offset to build at
+     */
+    public static Record buildRecordAtOffset(byte[] b, int offset) {
+        long type = LittleEndian.getUShort(b,offset+2);
+        long rlen = LittleEndian.getUInt(b,offset+4);
+
+        // Sanity check the length
+        int rleni = (int)rlen;
+        if(rleni < 0) { rleni = 0; }
+
+        return createRecordForType(type,b,offset,8+rleni);
+    }
+
+    /**
+     * Default method for finding child records of a container record
+     */
+    public static Record[] findChildRecords(byte[] b, int start, int len) {
+        List<Record> children = new ArrayList<>(5);
+
+        // Jump our little way along, creating records as we go
+        int pos = start;
+        while(pos <= (start+len-8)) {
+            long type = LittleEndian.getUShort(b,pos+2);
+            long rlen = LittleEndian.getUInt(b,pos+4);
+
+            // Sanity check the length
+            int rleni = (int)rlen;
+            if(rleni < 0) { rleni = 0; }
+
+            // Abort if first record is of type 0000 and length FFFF,
+            //  as that's a sign of a screwed up record
+            if(pos == 0 && type == 0L && rleni == 0xffff) {
+                throw new CorruptPowerPointFileException("Corrupt document - starts with record of type 0000 and length 0xFFFF");
+            }
+
+            Record r = createRecordForType(type,b,pos,8+rleni);
+            if(r != null) {
+                children.add(r);
+            }
+            pos += 8;
+            pos += rleni;
+        }
 
-		// Turn the vector into an array, and return
+        // Turn the vector into an array, and return
         return children.toArray(new Record[0]);
-	}
+    }
 
-	/**
-	 * For a given type (little endian bytes 3 and 4 in record header),
-	 *  byte array, start position and length:
-	 *  will return a Record object that will handle that record
-	 *
-	 * Remember that while PPT stores the record lengths as 8 bytes short
-	 *  (not including the size of the header), this code assumes you're
-	 *  passing in corrected lengths
-	 */
-	public static Record createRecordForType(long type, byte[] b, int start, int len) {
-		// We use the RecordTypes class to provide us with the right
-		//  class to use for a given type
-		// A spot of reflection gets us the (byte[],int,int) constructor
-		// From there, we instanciate the class
-		// Any special record handling occurs once we have the class
-		RecordTypes recordType = RecordTypes.forTypeID((short) type);
-		RecordConstructor c = recordType.recordConstructor;
-		if (c == null) {
-			// How odd. RecordTypes normally substitutes in
-			//  a default handler class if it has heard of the record
-			//  type but there's no support for it. Explicitly request
-			//  that now
-			LOG.atDebug().log(() -> new StringFormattedMessage("Known but unhandled record type %d (0x%04x) at offset %d", type, type, start));
-			c = RecordTypes.UnknownRecordPlaceholder.recordConstructor;
-		} else if (recordType == RecordTypes.UnknownRecordPlaceholder) {
-			LOG.atDebug().log(() -> new StringFormattedMessage("Unknown placeholder type %d (0x%04x) at offset %d", type, type, start));
-		}
-
-		final Record toReturn;
-		try {
-			toReturn = c.apply(b, start, len);
-		} catch(RuntimeException e) {
-			// Handle case of a corrupt last record, whose claimed length
-			//  would take us passed the end of the file
-			if(start + len > b.length ) {
-				LOG.atWarn().log("Warning: Skipping record of type {} at position {} which claims to be longer than the file! ({} vs {})", type, box(start), box(len), box(b.length - start));
-				return null;
-			}
-
-			throw new HSLFException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + e, e);
-		}
-
-		// Handling for special kinds of records follow
-
-		// If it's a position aware record, tell it where it is
-		if(toReturn instanceof PositionDependentRecord) {
-			PositionDependentRecord pdr = (PositionDependentRecord)toReturn;
-			pdr.setLastOnDiskOffset(start);
-		}
-
-		// Return the created record
-		return toReturn;
-	}
+    /**
+     * For a given type (little endian bytes 3 and 4 in record header),
+     *  byte array, start position and length:
+     *  will return a Record object that will handle that record
+     *
+     * Remember that while PPT stores the record lengths as 8 bytes short
+     *  (not including the size of the header), this code assumes you're
+     *  passing in corrected lengths
+     */
+    public static Record createRecordForType(long type, byte[] b, int start, int len) {
+        // We use the RecordTypes class to provide us with the right
+        //  class to use for a given type
+        // A spot of reflection gets us the (byte[],int,int) constructor
+        // From there, we instanciate the class
+        // Any special record handling occurs once we have the class
+        RecordTypes recordType = RecordTypes.forTypeID((short) type);
+        RecordConstructor c = recordType.recordConstructor;
+        if (c == null) {
+            // How odd. RecordTypes normally substitutes in
+            //  a default handler class if it has heard of the record
+            //  type but there's no support for it. Explicitly request
+            //  that now
+            LOG.atDebug().log(() -> new StringFormattedMessage("Known but unhandled record type %d (0x%04x) at offset %d", type, type, start));
+            c = RecordTypes.UnknownRecordPlaceholder.recordConstructor;
+        } else if (recordType == RecordTypes.UnknownRecordPlaceholder) {
+            LOG.atDebug().log(() -> new StringFormattedMessage("Unknown placeholder type %d (0x%04x) at offset %d", type, type, start));
+        }
+
+        final Record toReturn;
+        try {
+            toReturn = c.apply(b, start, len);
+        } catch(RuntimeException e) {
+            // Handle case of a corrupt last record, whose claimed length
+            //  would take us passed the end of the file
+            if(start + len > b.length ) {
+                LOG.atWarn().log("Warning: Skipping record of type {} at position {} which claims to be longer than the file! ({} vs {})", type, box(start), box(len), box(b.length - start));
+                return null;
+            }
+
+            throw new HSLFException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + e, e);
+        }
+
+        // Handling for special kinds of records follow
+
+        // If it's a position aware record, tell it where it is
+        if(toReturn instanceof PositionDependentRecord) {
+            PositionDependentRecord pdr = (PositionDependentRecord)toReturn;
+            pdr.setLastOnDiskOffset(start);
+        }
+
+        // Return the created record
+        return toReturn;
+    }
 
 
 }

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=1890122&r1=1890121&r2=1890122&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 Sat May 22 21:37:08 2021
@@ -23,13 +23,13 @@ package org.apache.poi.hslf.record;
 
 public abstract class RecordAtom extends Record
 {
-	/**
-	 * We are an atom
-	 */
-	public boolean isAnAtom() { return true; }
+    /**
+     * We are an atom
+     */
+    public boolean isAnAtom() { return true; }
 
-	/**
-	 * We're an atom, returns null
-	 */
-	public org.apache.poi.hslf.record.Record[] getChildRecords() { return null; }
+    /**
+     * We're an atom, returns null
+     */
+    public org.apache.poi.hslf.record.Record[] getChildRecords() { return null; }
 }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordContainer.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordContainer.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordContainer.java Sat May 22 21:37:08 2021
@@ -35,102 +35,102 @@ import org.apache.poi.util.LittleEndian;
 
 public abstract class RecordContainer extends Record
 {
-	protected Record[] _children;
+    protected Record[] _children;
 
-	/**
-	 * Return any children
-	 */
-	@Override
+    /**
+     * Return any children
+     */
+    @Override
     public org.apache.poi.hslf.record.Record[] getChildRecords() { return _children; }
 
-	/**
-	 * We're not an atom
-	 */
-	@Override
+    /**
+     * We're not an atom
+     */
+    @Override
     public boolean isAnAtom() { return false; }
 
 
-	/* ===============================================================
-	 *                   Internal Move Helpers
-	 * ===============================================================
-	 */
-
-	/**
-	 * Finds the location of the given child record
-	 */
-	private int findChildLocation(Record child) {
-	    int i=0;
-		for(org.apache.poi.hslf.record.Record r : _children) {
-			if (r.equals(child)) {
-				return i;
-			}
-			i++;
-		}
-		return -1;
-	}
-
-	/**
-	 * Adds a child record, at the very end.
-	 * @param newChild The child record to add
-	 * @return the position of the added child
-	 */
-	private int appendChild(Record newChild) {
-		// Copy over, and pop the child in at the end
-		Record[] nc = Arrays.copyOf(_children, _children.length+1, org.apache.poi.hslf.record.Record[].class);
-		// Switch the arrays
-		nc[_children.length] = newChild;
-		_children = nc;
-		return _children.length;
-	}
-
-	/**
-	 * Adds the given new Child Record at the given location,
-	 *  shuffling everything from there on down by one
-	 *
-	 * @param newChild The record to be added as child-record.
-	 * @param position The index where the child should be added, 0-based
-	 */
-	private void addChildAt(Record newChild, int position) {
-		// Firstly, have the child added in at the end
-		appendChild(newChild);
-
-		// Now, have them moved to the right place
-		moveChildRecords( (_children.length-1), position, 1 );
-	}
-
-	/**
-	 * Moves {@code number} child records from {@code oldLoc} to {@code newLoc}.
-	 * @param oldLoc the current location of the records to move
-	 * @param newLoc the new location for the records
-	 * @param number the number of records to move
-	 */
-	private void moveChildRecords(int oldLoc, int newLoc, int number) {
-		if(oldLoc == newLoc) { return; }
-		if(number == 0) { return; }
-
-		// Check that we're not asked to move too many
-		if(oldLoc+number > _children.length) {
-			throw new IllegalArgumentException("Asked to move more records than there are!");
-		}
-
-		// Do the move
-		ArrayUtil.arrayMoveWithin(_children, oldLoc, newLoc, number);
-	}
-
-
-	/**
-	 * Finds the first child record of the given type,
-	 *  or null if none of the child records are of the
-	 *  given type. Does not descend.
-	 */
-	public org.apache.poi.hslf.record.Record findFirstOfType(long type) {
-		for (org.apache.poi.hslf.record.Record r : _children) {
-			if (r.getRecordType() == type) {
-				return r;
-			}
-		}
-		return null;
-	}
+    /* ===============================================================
+     *                   Internal Move Helpers
+     * ===============================================================
+     */
+
+    /**
+     * Finds the location of the given child record
+     */
+    private int findChildLocation(Record child) {
+        int i=0;
+        for(org.apache.poi.hslf.record.Record r : _children) {
+            if (r.equals(child)) {
+                return i;
+            }
+            i++;
+        }
+        return -1;
+    }
+
+    /**
+     * Adds a child record, at the very end.
+     * @param newChild The child record to add
+     * @return the position of the added child
+     */
+    private int appendChild(Record newChild) {
+        // Copy over, and pop the child in at the end
+        Record[] nc = Arrays.copyOf(_children, _children.length+1, org.apache.poi.hslf.record.Record[].class);
+        // Switch the arrays
+        nc[_children.length] = newChild;
+        _children = nc;
+        return _children.length;
+    }
+
+    /**
+     * Adds the given new Child Record at the given location,
+     *  shuffling everything from there on down by one
+     *
+     * @param newChild The record to be added as child-record.
+     * @param position The index where the child should be added, 0-based
+     */
+    private void addChildAt(Record newChild, int position) {
+        // Firstly, have the child added in at the end
+        appendChild(newChild);
+
+        // Now, have them moved to the right place
+        moveChildRecords( (_children.length-1), position, 1 );
+    }
+
+    /**
+     * Moves {@code number} child records from {@code oldLoc} to {@code newLoc}.
+     * @param oldLoc the current location of the records to move
+     * @param newLoc the new location for the records
+     * @param number the number of records to move
+     */
+    private void moveChildRecords(int oldLoc, int newLoc, int number) {
+        if(oldLoc == newLoc) { return; }
+        if(number == 0) { return; }
+
+        // Check that we're not asked to move too many
+        if(oldLoc+number > _children.length) {
+            throw new IllegalArgumentException("Asked to move more records than there are!");
+        }
+
+        // Do the move
+        ArrayUtil.arrayMoveWithin(_children, oldLoc, newLoc, number);
+    }
+
+
+    /**
+     * Finds the first child record of the given type,
+     *  or null if none of the child records are of the
+     *  given type. Does not descend.
+     */
+    public org.apache.poi.hslf.record.Record findFirstOfType(long type) {
+        for (org.apache.poi.hslf.record.Record r : _children) {
+            if (r.getRecordType() == type) {
+                return r;
+            }
+        }
+        return null;
+    }
 
     /**
      * Remove a child record from this record container
@@ -153,55 +153,55 @@ public abstract class RecordContainer ex
     }
 
     /* ===============================================================
-	 *                   External Move Methods
-	 * ===============================================================
-	 */
-
-	/**
-	 * Add a new child record onto a record's list of children.
-	 *
-	 * @param newChild the child record to be added
-	 * @return the position of the added child within the list, i.e. the last index
-	 */
-	public int appendChildRecord(Record newChild) {
-		return appendChild(newChild);
-	}
-
-	/**
-	 * Adds the given Child Record after the supplied record
-	 * @param newChild The record to add as new child.
-	 * @param after The record after which the given record should be added.
-	 * @return the position of the added child within the list
-	 */
-	public int addChildAfter(Record newChild, Record after) {
-		// Decide where we're going to put it
-		int loc = findChildLocation(after);
-		if(loc == -1) {
-			throw new IllegalArgumentException("Asked to add a new child after another record, but that record wasn't one of our children!");
-		}
-
-		// Add one place after the supplied record
-		addChildAt(newChild, loc+1);
-		return loc+1;
-	}
-
-	/**
-	 * Adds the given Child Record before the supplied record
-	 * @param newChild The record to add as new child.
-	 * @param before The record before which the given record should be added.
+     *                   External Move Methods
+     * ===============================================================
+     */
+
+    /**
+     * Add a new child record onto a record's list of children.
+     *
+     * @param newChild the child record to be added
+     * @return the position of the added child within the list, i.e. the last index
+     */
+    public int appendChildRecord(Record newChild) {
+        return appendChild(newChild);
+    }
+
+    /**
+     * Adds the given Child Record after the supplied record
+     * @param newChild The record to add as new child.
+     * @param after The record after which the given record should be added.
      * @return the position of the added child within the list
-	 */
-	public int addChildBefore(Record newChild, Record before) {
-		// Decide where we're going to put it
-		int loc = findChildLocation(before);
-		if(loc == -1) {
-			throw new IllegalArgumentException("Asked to add a new child before another record, but that record wasn't one of our children!");
-		}
-
-		// Add at the place of the supplied record
-		addChildAt(newChild, loc);
-		return loc;
-	}
+     */
+    public int addChildAfter(Record newChild, Record after) {
+        // Decide where we're going to put it
+        int loc = findChildLocation(after);
+        if(loc == -1) {
+            throw new IllegalArgumentException("Asked to add a new child after another record, but that record wasn't one of our children!");
+        }
+
+        // Add one place after the supplied record
+        addChildAt(newChild, loc+1);
+        return loc+1;
+    }
+
+    /**
+     * Adds the given Child Record before the supplied record
+     * @param newChild The record to add as new child.
+     * @param before The record before which the given record should be added.
+     * @return the position of the added child within the list
+     */
+    public int addChildBefore(Record newChild, Record before) {
+        // Decide where we're going to put it
+        int loc = findChildLocation(before);
+        if(loc == -1) {
+            throw new IllegalArgumentException("Asked to add a new child before another record, but that record wasn't one of our children!");
+        }
+
+        // Add at the place of the supplied record
+        addChildAt(newChild, loc);
+        return loc;
+    }
 
     /**
      * Set child records.
@@ -212,46 +212,46 @@ public abstract class RecordContainer ex
         this._children = records.clone();
     }
 
-	/* ===============================================================
-	 *                 External Serialisation Methods
-	 * ===============================================================
-	 */
-
-	/**
-	 * Write out our header, and our children.
-	 * @param headerA the first byte of the header
-	 * @param headerB the second byte of the header
-	 * @param type the record type
-	 * @param children our child records
-	 * @param out the stream to write to
-	 */
-	public void writeOut(byte headerA, byte headerB, long type, Record[] children, OutputStream out) throws IOException {
-		// Create a UnsynchronizedByteArrayOutputStream to hold everything in
-		UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
-
-		// Write out our header, less the size
-		baos.write(new byte[] {headerA,headerB});
-		byte[] typeB = new byte[2];
-		LittleEndian.putShort(typeB,0,(short)type);
-		baos.write(typeB);
-		baos.write(new byte[] {0,0,0,0});
-
-		// Write out our children
-		for (Record aChildren : children) {
-			aChildren.writeOut(baos);
-		}
-
-		// Grab the bytes back
-		byte[] toWrite = baos.toByteArray();
-
-		// Update our header with the size
-		// Don't forget to knock 8 more off, since we don't include the
-		//  header in the size
-		LittleEndian.putInt(toWrite,4,(toWrite.length-8));
-
-		// Write out the bytes
-		out.write(toWrite);
-	}
+    /* ===============================================================
+     *                 External Serialisation Methods
+     * ===============================================================
+     */
+
+    /**
+     * Write out our header, and our children.
+     * @param headerA the first byte of the header
+     * @param headerB the second byte of the header
+     * @param type the record type
+     * @param children our child records
+     * @param out the stream to write to
+     */
+    public void writeOut(byte headerA, byte headerB, long type, Record[] children, OutputStream out) throws IOException {
+        // Create a UnsynchronizedByteArrayOutputStream to hold everything in
+        UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+
+        // Write out our header, less the size
+        baos.write(new byte[] {headerA,headerB});
+        byte[] typeB = new byte[2];
+        LittleEndian.putShort(typeB,0,(short)type);
+        baos.write(typeB);
+        baos.write(new byte[] {0,0,0,0});
+
+        // Write out our children
+        for (Record aChildren : children) {
+            aChildren.writeOut(baos);
+        }
+
+        // Grab the bytes back
+        byte[] toWrite = baos.toByteArray();
+
+        // Update our header with the size
+        // Don't forget to knock 8 more off, since we don't include the
+        //  header in the size
+        LittleEndian.putInt(toWrite,4,(toWrite.length-8));
+
+        // Write out the bytes
+        out.write(toWrite);
+    }
 
     /**
      * Find the records that are parent-aware, and tell them who their parent is
@@ -270,8 +270,8 @@ public abstract class RecordContainer ex
         }
     }
 
-	@Override
-	public Map<String, Supplier<?>> getGenericProperties() {
-		return null;
-	}
+    @Override
+    public Map<String, Supplier<?>> getGenericProperties() {
+        return null;
+    }
 }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Slide.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Slide.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Slide.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Slide.java Sat May 22 21:37:08 2021
@@ -30,84 +30,84 @@ import org.apache.poi.util.LittleEndian;
 
 public final class Slide extends SheetContainer
 {
-	private byte[] _header;
-	private static long _type = 1006l;
+    private byte[] _header;
+    private static long _type = 1006l;
 
-	// Links to our more interesting children
-	private SlideAtom slideAtom;
-	private PPDrawing ppDrawing;
+    // Links to our more interesting children
+    private SlideAtom slideAtom;
+    private PPDrawing ppDrawing;
     private ColorSchemeAtom _colorScheme;
 
-	/**
-	 * Returns the SlideAtom of this Slide
-	 */
-	public SlideAtom getSlideAtom() { return slideAtom; }
-
-	/**
-	 * Returns the PPDrawing of this Slide, which has all the
-	 *  interesting data in it
-	 */
-	public PPDrawing getPPDrawing() { return ppDrawing; }
-
-
-	/**
-	 * Set things up, and find our more interesting children
-	 */
-	protected Slide(byte[] source, int start, int len) {
-		// Grab the header
-		_header = Arrays.copyOfRange(source, start, start+8);
-
-		// Find our children
-		_children = Record.findChildRecords(source,start+8,len-8);
-
-		// Find the interesting ones in there
-		for (Record child : _children) {
-			if (child instanceof SlideAtom) {
-				slideAtom = (SlideAtom) child;
-			} else if (child instanceof PPDrawing) {
-				ppDrawing = (PPDrawing) child;
-			}
-
-			if (ppDrawing != null && child instanceof ColorSchemeAtom) {
-				_colorScheme = (ColorSchemeAtom) child;
-			}
-		}
-	}
-
-	/**
-	 * Create a new, empty, Slide, along with its required
-	 *  child records.
-	 */
-	public Slide(){
-		_header = new byte[8];
-		LittleEndian.putUShort(_header, 0, 15);
-		LittleEndian.putUShort(_header, 2, (int)_type);
-		LittleEndian.putInt(_header, 4, 0);
-
-		slideAtom = new SlideAtom();
-		ppDrawing = new PPDrawing();
-
-		ColorSchemeAtom colorAtom = new ColorSchemeAtom();
-
-		_children = new org.apache.poi.hslf.record.Record[] {
-			slideAtom,
-			ppDrawing,
-			colorAtom
-		};
-	}
-
-	/**
-	 * We are of type 1006
-	 */
-	public long getRecordType() { return _type; }
-
-	/**
-	 * Write the contents of the record back, so it can be written
-	 *  to disk
-	 */
-	public void writeOut(OutputStream out) throws IOException {
-		writeOut(_header[0],_header[1],_type,_children,out);
-	}
+    /**
+     * Returns the SlideAtom of this Slide
+     */
+    public SlideAtom getSlideAtom() { return slideAtom; }
+
+    /**
+     * Returns the PPDrawing of this Slide, which has all the
+     *  interesting data in it
+     */
+    public PPDrawing getPPDrawing() { return ppDrawing; }
+
+
+    /**
+     * Set things up, and find our more interesting children
+     */
+    protected Slide(byte[] source, int start, int len) {
+        // Grab the header
+        _header = Arrays.copyOfRange(source, start, start+8);
+
+        // Find our children
+        _children = Record.findChildRecords(source,start+8,len-8);
+
+        // Find the interesting ones in there
+        for (Record child : _children) {
+            if (child instanceof SlideAtom) {
+                slideAtom = (SlideAtom) child;
+            } else if (child instanceof PPDrawing) {
+                ppDrawing = (PPDrawing) child;
+            }
+
+            if (ppDrawing != null && child instanceof ColorSchemeAtom) {
+                _colorScheme = (ColorSchemeAtom) child;
+            }
+        }
+    }
+
+    /**
+     * Create a new, empty, Slide, along with its required
+     *  child records.
+     */
+    public Slide(){
+        _header = new byte[8];
+        LittleEndian.putUShort(_header, 0, 15);
+        LittleEndian.putUShort(_header, 2, (int)_type);
+        LittleEndian.putInt(_header, 4, 0);
+
+        slideAtom = new SlideAtom();
+        ppDrawing = new PPDrawing();
+
+        ColorSchemeAtom colorAtom = new ColorSchemeAtom();
+
+        _children = new org.apache.poi.hslf.record.Record[] {
+            slideAtom,
+            ppDrawing,
+            colorAtom
+        };
+    }
+
+    /**
+     * We are of type 1006
+     */
+    public long getRecordType() { return _type; }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     *  to disk
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        writeOut(_header[0],_header[1],_type,_children,out);
+    }
 
     public ColorSchemeAtom getColorScheme(){
         return _colorScheme;

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=1890122&r1=1890121&r2=1890122&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 Sat May 22 21:37:08 2021
@@ -38,137 +38,137 @@ 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;
+    //arbitrarily selected; may need to increase
+    private static final int MAX_RECORD_LENGTH = 1_000_000;
 
-	private byte[] _header;
-	private static long _type = 1007l;
+    private byte[] _header;
+    private static long _type = 1007l;
 
-	private int masterID;
-	private int notesID;
+    private int masterID;
+    private int notesID;
 
-	private boolean followMasterObjects;
-	private boolean followMasterScheme;
-	private boolean followMasterBackground;
-	private SlideAtomLayout layoutAtom;
-	private byte[] reserved;
+    private boolean followMasterObjects;
+    private boolean followMasterScheme;
+    private boolean followMasterBackground;
+    private SlideAtomLayout layoutAtom;
+    private byte[] reserved;
 
 
-	/** Get the ID of the master slide used. 0 if this is a master slide, otherwise -2147483648 */
-	public int getMasterID() { return masterID; }
+    /** Get the ID of the master slide used. 0 if this is a master slide, otherwise -2147483648 */
+    public int getMasterID() { return masterID; }
     /** Change slide master.  */
     public void setMasterID(int id) { masterID = id; }
-	/** Get the ID of the notes for this slide. 0 if doesn't have one */
-	public int getNotesID()  { return notesID; }
-	/** Get the embedded SSlideLayoutAtom */
-	public SlideAtomLayout getSSlideLayoutAtom() { return layoutAtom; }
-
-	/** Change the ID of the notes for this slide. 0 if it no longer has one */
-	public void setNotesID(int id) { notesID = id; }
-
-	public boolean getFollowMasterObjects()    { return followMasterObjects; }
-	public boolean getFollowMasterScheme()     { return followMasterScheme; }
-	public boolean getFollowMasterBackground() { return followMasterBackground; }
-	public void setFollowMasterObjects(boolean flag)    { followMasterObjects = flag; }
-	public void setFollowMasterScheme(boolean flag)     { followMasterScheme = flag; }
-	public void setFollowMasterBackground(boolean flag) { followMasterBackground = flag; }
-
-
-	/* *************** record code follows ********************** */
-
-	/**
-	 * For the Slide Atom
-	 */
-	protected SlideAtom(byte[] source, int start, int len) {
-		// Sanity Checking
-		if(len < 30) { len = 30; }
-
-		// Get the header
-		_header = Arrays.copyOfRange(source, start, start+8);
-
-		// Grab the 12 bytes that is "SSlideLayoutAtom"
-		byte[] SSlideLayoutAtomData = Arrays.copyOfRange(source,start+8, start+12+8);
-		// Use them to build up the SSlideLayoutAtom
-		layoutAtom = new SlideAtomLayout(SSlideLayoutAtomData);
-
-		// Get the IDs of the master and notes
-		masterID = LittleEndian.getInt(source,start+12+8);
-		notesID = LittleEndian.getInt(source,start+16+8);
-
-		// Grok the flags, stored as bits
-		int flags = LittleEndian.getUShort(source,start+20+8);
-		followMasterBackground = (flags & 4) == 4;
-		followMasterScheme = (flags & 2) == 2;
-		followMasterObjects = (flags & 1) == 1;
-
-		// 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);
-	}
-
-	/**
-	 * Create a new SlideAtom, to go with a new Slide
-	 */
-	public SlideAtom(){
-		_header = new byte[8];
-		LittleEndian.putUShort(_header, 0, 2);
-		LittleEndian.putUShort(_header, 2, (int)_type);
-		LittleEndian.putInt(_header, 4, 24);
-
-		byte[] ssdate = new byte[12];
-		layoutAtom = new SlideAtomLayout(ssdate);
-		layoutAtom.setGeometryType(SlideLayoutType.BLANK_SLIDE);
-
-		followMasterObjects = true;
-		followMasterScheme = true;
-		followMasterBackground = true;
-		masterID = USES_MASTER_SLIDE_ID; // -2147483648;
-		notesID = 0;
-		reserved = new byte[2];
-	}
-
-	/**
-	 * We are of type 1007
-	 */
-	@Override
+    /** Get the ID of the notes for this slide. 0 if doesn't have one */
+    public int getNotesID()  { return notesID; }
+    /** Get the embedded SSlideLayoutAtom */
+    public SlideAtomLayout getSSlideLayoutAtom() { return layoutAtom; }
+
+    /** Change the ID of the notes for this slide. 0 if it no longer has one */
+    public void setNotesID(int id) { notesID = id; }
+
+    public boolean getFollowMasterObjects()    { return followMasterObjects; }
+    public boolean getFollowMasterScheme()     { return followMasterScheme; }
+    public boolean getFollowMasterBackground() { return followMasterBackground; }
+    public void setFollowMasterObjects(boolean flag)    { followMasterObjects = flag; }
+    public void setFollowMasterScheme(boolean flag)     { followMasterScheme = flag; }
+    public void setFollowMasterBackground(boolean flag) { followMasterBackground = flag; }
+
+
+    /* *************** record code follows ********************** */
+
+    /**
+     * For the Slide Atom
+     */
+    protected SlideAtom(byte[] source, int start, int len) {
+        // Sanity Checking
+        if(len < 30) { len = 30; }
+
+        // Get the header
+        _header = Arrays.copyOfRange(source, start, start+8);
+
+        // Grab the 12 bytes that is "SSlideLayoutAtom"
+        byte[] SSlideLayoutAtomData = Arrays.copyOfRange(source,start+8, start+12+8);
+        // Use them to build up the SSlideLayoutAtom
+        layoutAtom = new SlideAtomLayout(SSlideLayoutAtomData);
+
+        // Get the IDs of the master and notes
+        masterID = LittleEndian.getInt(source,start+12+8);
+        notesID = LittleEndian.getInt(source,start+16+8);
+
+        // Grok the flags, stored as bits
+        int flags = LittleEndian.getUShort(source,start+20+8);
+        followMasterBackground = (flags & 4) == 4;
+        followMasterScheme = (flags & 2) == 2;
+        followMasterObjects = (flags & 1) == 1;
+
+        // 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);
+    }
+
+    /**
+     * Create a new SlideAtom, to go with a new Slide
+     */
+    public SlideAtom(){
+        _header = new byte[8];
+        LittleEndian.putUShort(_header, 0, 2);
+        LittleEndian.putUShort(_header, 2, (int)_type);
+        LittleEndian.putInt(_header, 4, 24);
+
+        byte[] ssdate = new byte[12];
+        layoutAtom = new SlideAtomLayout(ssdate);
+        layoutAtom.setGeometryType(SlideLayoutType.BLANK_SLIDE);
+
+        followMasterObjects = true;
+        followMasterScheme = true;
+        followMasterBackground = true;
+        masterID = USES_MASTER_SLIDE_ID; // -2147483648;
+        notesID = 0;
+        reserved = new byte[2];
+    }
+
+    /**
+     * We are of type 1007
+     */
+    @Override
     public long getRecordType() { return _type; }
 
-	/**
-	 * Write the contents of the record back, so it can be written
-	 *  to disk
-	 */
-	@Override
+    /**
+     * Write the contents of the record back, so it can be written
+     *  to disk
+     */
+    @Override
     public void writeOut(OutputStream out) throws IOException {
-		// Header
-		out.write(_header);
+        // Header
+        out.write(_header);
 
-		// SSSlideLayoutAtom stuff
-		layoutAtom.writeOut(out);
+        // SSSlideLayoutAtom stuff
+        layoutAtom.writeOut(out);
 
-		// IDs
-		writeLittleEndian(masterID,out);
-		writeLittleEndian(notesID,out);
-
-		// Flags
-		short flags = 0;
-		if(followMasterObjects)    { flags += 1; }
-		if(followMasterScheme)     { flags += 2; }
-		if(followMasterBackground) { flags += 4; }
-		writeLittleEndian(flags,out);
-
-		// Reserved data
-		out.write(reserved);
-	}
-
-	@Override
-	public Map<String, Supplier<?>> getGenericProperties() {
-		return GenericRecordUtil.getGenericProperties(
-			"masterID", this::getMasterID,
-			"notesID", this::getNotesID,
-			"followMasterObjects", this::getFollowMasterObjects,
-			"followMasterScheme", this::getFollowMasterScheme,
-			"followMasterBackground", this::getFollowMasterBackground,
-			"layoutAtom", this::getSSlideLayoutAtom
-		);
-	}
+        // IDs
+        writeLittleEndian(masterID,out);
+        writeLittleEndian(notesID,out);
+
+        // Flags
+        short flags = 0;
+        if(followMasterObjects)    { flags += 1; }
+        if(followMasterScheme)     { flags += 2; }
+        if(followMasterBackground) { flags += 4; }
+        writeLittleEndian(flags,out);
+
+        // Reserved data
+        out.write(reserved);
+    }
+
+    @Override
+    public Map<String, Supplier<?>> getGenericProperties() {
+        return GenericRecordUtil.getGenericProperties(
+            "masterID", this::getMasterID,
+            "notesID", this::getNotesID,
+            "followMasterObjects", this::getFollowMasterObjects,
+            "followMasterScheme", this::getFollowMasterScheme,
+            "followMasterBackground", this::getFollowMasterBackground,
+            "layoutAtom", this::getSSlideLayoutAtom
+        );
+    }
 }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java Sat May 22 21:37:08 2021
@@ -46,155 +46,155 @@ import org.apache.poi.util.LittleEndian;
 
 // For now, pretend to be an atom
 public final class SlideListWithText extends RecordContainer {
-	private static final long _type = RecordTypes.SlideListWithText.typeID;
+    private static final long _type = RecordTypes.SlideListWithText.typeID;
 
-	/**
-	 * Instance filed of the record header indicates that this SlideListWithText stores
-	 * references to slides
-	 */
-	public static final int SLIDES = 0;
-	/**
-	 * Instance filed of the record header indicates that this SlideListWithText stores
-	 * references to master slides
-	 */
-	public static final int MASTER = 1;
-	/**
-	 * Instance filed of the record header indicates that this SlideListWithText stores
-	 * references to notes
-	 */
-	public static final int NOTES = 2;
-
-	private final byte[] _header;
-
-	private SlideAtomsSet[] slideAtomsSets;
-
-	/**
-	 * Create a new holder for slide records
-	 */
-	protected SlideListWithText(byte[] source, int start, int len) {
-		// Grab the header
-		_header = Arrays.copyOfRange(source, start, start+8);
-
-		// Find our children
-		_children = Record.findChildRecords(source,start+8,len-8);
-
-		// Group our children together into SlideAtomsSets
-		// That way, model layer code can just grab the sets to use,
-		//  without having to try to match the children together
-		List<SlideAtomsSet> sets = new ArrayList<>();
-		for(int i=0; i<_children.length; i++) {
-			if(_children[i] instanceof SlidePersistAtom) {
-				// Find where the next SlidePersistAtom is
-				int endPos = i+1;
-				while(endPos < _children.length && !(_children[endPos] instanceof SlidePersistAtom)) {
-					endPos += 1;
-				}
-
-				int clen = endPos - i - 1;
-
-				// Create a SlideAtomsSets, not caring if they're empty
-				//if(emptySet) { continue; }
-				org.apache.poi.hslf.record.Record[] spaChildren = Arrays.copyOfRange(_children,i+1, i+1+clen, org.apache.poi.hslf.record.Record[].class);
-				SlideAtomsSet set = new SlideAtomsSet((SlidePersistAtom)_children[i],spaChildren);
-				sets.add(set);
-
-				// Wind on
-				i += clen;
-			}
-		}
-
-		// Turn the list into an array
-		slideAtomsSets = sets.toArray(new SlideAtomsSet[0]);
-	}
-
-	/**
-	 * Create a new, empty, SlideListWithText
-	 */
-	public SlideListWithText(){
-		_header = new byte[8];
-		LittleEndian.putUShort(_header, 0, 15);
-		LittleEndian.putUShort(_header, 2, (int)_type);
-		LittleEndian.putInt(_header, 4, 0);
-
-		// We have no children to start with
-		_children = new org.apache.poi.hslf.record.Record[0];
-		slideAtomsSets = new SlideAtomsSet[0];
-	}
-
-	/**
-	 * Add a new SlidePersistAtom, to the end of the current list,
-	 *  and update the internal list of SlidePersistAtoms
-	 */
-	public void addSlidePersistAtom(SlidePersistAtom spa) {
-		// Add the new SlidePersistAtom at the end
-		appendChildRecord(spa);
-
-		SlideAtomsSet newSAS = new SlideAtomsSet(spa, new org.apache.poi.hslf.record.Record[0]);
-
-		// Update our SlideAtomsSets with this
-		SlideAtomsSet[] sas = new SlideAtomsSet[slideAtomsSets.length+1];
-		System.arraycopy(slideAtomsSets, 0, sas, 0, slideAtomsSets.length);
-		sas[sas.length-1] = newSAS;
-		slideAtomsSets = sas;
-	}
-
-	public int getInstance(){
-		return LittleEndian.getShort(_header, 0) >> 4;
-	}
-
-	public void setInstance(int inst){
-		LittleEndian.putShort(_header, 0, (short)((inst << 4) | 0xF));
-	}
-
-	/**
-	 * Get access to the SlideAtomsSets of the children of this record
-	 */
-	public SlideAtomsSet[] getSlideAtomsSets() {
-	    return slideAtomsSets;
-    }
-
-	/**
-	* Get access to the SlideAtomsSets of the children of this record
-	*/
-	public void setSlideAtomsSets( SlideAtomsSet[] sas ) {
-	    slideAtomsSets = sas.clone();
-    }
-
-	/**
-	 * Return the value we were given at creation
-	 */
-	@Override
-	public long getRecordType() { return _type; }
-
-	/**
-	 * Write the contents of the record back, so it can be written
-	 *  to disk
-	 */
-	@Override
-	public void writeOut(OutputStream out) throws IOException {
-		writeOut(_header[0],_header[1],_type,_children,out);
-	}
-
-	/**
-	 * Inner class to wrap up a matching set of records that hold the
-	 *  text for a given sheet. Contains the leading SlidePersistAtom,
-	 *  and all of the records until the next SlidePersistAtom. This
-	 *  includes sets of TextHeaderAtom and TextBytesAtom/TextCharsAtom,
-	 *  along with some others.
-	 */
-	public static class SlideAtomsSet {
-		private final SlidePersistAtom slidePersistAtom;
-		private final org.apache.poi.hslf.record.Record[] slideRecords;
-
-		/** Get the SlidePersistAtom, which gives details on the Slide this text is associated with */
-		public SlidePersistAtom getSlidePersistAtom() { return slidePersistAtom; }
-		/** Get the Text related records for this slide */
-		public org.apache.poi.hslf.record.Record[] getSlideRecords() { return slideRecords; }
-
-		/** Create one to hold the Records for one Slide's text */
-		public SlideAtomsSet(SlidePersistAtom s, org.apache.poi.hslf.record.Record[] r) {
-			slidePersistAtom = s;
-			slideRecords = r.clone();
-		}
-	}
+    /**
+     * Instance filed of the record header indicates that this SlideListWithText stores
+     * references to slides
+     */
+    public static final int SLIDES = 0;
+    /**
+     * Instance filed of the record header indicates that this SlideListWithText stores
+     * references to master slides
+     */
+    public static final int MASTER = 1;
+    /**
+     * Instance filed of the record header indicates that this SlideListWithText stores
+     * references to notes
+     */
+    public static final int NOTES = 2;
+
+    private final byte[] _header;
+
+    private SlideAtomsSet[] slideAtomsSets;
+
+    /**
+     * Create a new holder for slide records
+     */
+    protected SlideListWithText(byte[] source, int start, int len) {
+        // Grab the header
+        _header = Arrays.copyOfRange(source, start, start+8);
+
+        // Find our children
+        _children = Record.findChildRecords(source,start+8,len-8);
+
+        // Group our children together into SlideAtomsSets
+        // That way, model layer code can just grab the sets to use,
+        //  without having to try to match the children together
+        List<SlideAtomsSet> sets = new ArrayList<>();
+        for(int i=0; i<_children.length; i++) {
+            if(_children[i] instanceof SlidePersistAtom) {
+                // Find where the next SlidePersistAtom is
+                int endPos = i+1;
+                while(endPos < _children.length && !(_children[endPos] instanceof SlidePersistAtom)) {
+                    endPos += 1;
+                }
+
+                int clen = endPos - i - 1;
+
+                // Create a SlideAtomsSets, not caring if they're empty
+                //if(emptySet) { continue; }
+                org.apache.poi.hslf.record.Record[] spaChildren = Arrays.copyOfRange(_children,i+1, i+1+clen, org.apache.poi.hslf.record.Record[].class);
+                SlideAtomsSet set = new SlideAtomsSet((SlidePersistAtom)_children[i],spaChildren);
+                sets.add(set);
+
+                // Wind on
+                i += clen;
+            }
+        }
+
+        // Turn the list into an array
+        slideAtomsSets = sets.toArray(new SlideAtomsSet[0]);
+    }
+
+    /**
+     * Create a new, empty, SlideListWithText
+     */
+    public SlideListWithText(){
+        _header = new byte[8];
+        LittleEndian.putUShort(_header, 0, 15);
+        LittleEndian.putUShort(_header, 2, (int)_type);
+        LittleEndian.putInt(_header, 4, 0);
+
+        // We have no children to start with
+        _children = new org.apache.poi.hslf.record.Record[0];
+        slideAtomsSets = new SlideAtomsSet[0];
+    }
+
+    /**
+     * Add a new SlidePersistAtom, to the end of the current list,
+     *  and update the internal list of SlidePersistAtoms
+     */
+    public void addSlidePersistAtom(SlidePersistAtom spa) {
+        // Add the new SlidePersistAtom at the end
+        appendChildRecord(spa);
+
+        SlideAtomsSet newSAS = new SlideAtomsSet(spa, new org.apache.poi.hslf.record.Record[0]);
+
+        // Update our SlideAtomsSets with this
+        SlideAtomsSet[] sas = new SlideAtomsSet[slideAtomsSets.length+1];
+        System.arraycopy(slideAtomsSets, 0, sas, 0, slideAtomsSets.length);
+        sas[sas.length-1] = newSAS;
+        slideAtomsSets = sas;
+    }
+
+    public int getInstance(){
+        return LittleEndian.getShort(_header, 0) >> 4;
+    }
+
+    public void setInstance(int inst){
+        LittleEndian.putShort(_header, 0, (short)((inst << 4) | 0xF));
+    }
+
+    /**
+     * Get access to the SlideAtomsSets of the children of this record
+     */
+    public SlideAtomsSet[] getSlideAtomsSets() {
+        return slideAtomsSets;
+    }
+
+    /**
+    * Get access to the SlideAtomsSets of the children of this record
+    */
+    public void setSlideAtomsSets( SlideAtomsSet[] sas ) {
+        slideAtomsSets = sas.clone();
+    }
+
+    /**
+     * Return the value we were given at creation
+     */
+    @Override
+    public long getRecordType() { return _type; }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     *  to disk
+     */
+    @Override
+    public void writeOut(OutputStream out) throws IOException {
+        writeOut(_header[0],_header[1],_type,_children,out);
+    }
+
+    /**
+     * Inner class to wrap up a matching set of records that hold the
+     *  text for a given sheet. Contains the leading SlidePersistAtom,
+     *  and all of the records until the next SlidePersistAtom. This
+     *  includes sets of TextHeaderAtom and TextBytesAtom/TextCharsAtom,
+     *  along with some others.
+     */
+    public static class SlideAtomsSet {
+        private final SlidePersistAtom slidePersistAtom;
+        private final org.apache.poi.hslf.record.Record[] slideRecords;
+
+        /** Get the SlidePersistAtom, which gives details on the Slide this text is associated with */
+        public SlidePersistAtom getSlidePersistAtom() { return slidePersistAtom; }
+        /** Get the Text related records for this slide */
+        public org.apache.poi.hslf.record.Record[] getSlideRecords() { return slideRecords; }
+
+        /** Create one to hold the Records for one Slide's text */
+        public SlideAtomsSet(SlidePersistAtom s, org.apache.poi.hslf.record.Record[] r) {
+            slidePersistAtom = s;
+            slideRecords = r.clone();
+        }
+    }
 }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlidePersistAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlidePersistAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlidePersistAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlidePersistAtom.java Sat May 22 21:37:08 2021
@@ -35,123 +35,123 @@ import org.apache.poi.util.LittleEndian;
  */
 public final class SlidePersistAtom extends RecordAtom {
 
-	//arbitrarily selected; may need to increase
-	private static final int MAX_RECORD_LENGTH = 32;
+    //arbitrarily selected; may need to increase
+    private static final int MAX_RECORD_LENGTH = 32;
 
-	private static final long _type = 1011l;
-	private static final int HAS_SHAPES_OTHER_THAN_PLACEHOLDERS = 4;
+    private static final long _type = 1011l;
+    private static final int HAS_SHAPES_OTHER_THAN_PLACEHOLDERS = 4;
 
-	private static final int[] FLAGS_MASKS = { HAS_SHAPES_OTHER_THAN_PLACEHOLDERS };
-	private static final String[] FLAGS_NAMES = { "HAS_SHAPES_OTHER_THAN_PLACEHOLDERS" };
+    private static final int[] FLAGS_MASKS = { HAS_SHAPES_OTHER_THAN_PLACEHOLDERS };
+    private static final String[] FLAGS_NAMES = { "HAS_SHAPES_OTHER_THAN_PLACEHOLDERS" };
 
 
-	private final byte[] _header;
-
-	/** Slide reference ID. Should correspond to the PersistPtr "sheet ID" of the matching slide/notes record */
-	private int refID;
-	private int flags;
-
-	/** Number of placeholder texts that will follow in the SlideListWithText */
-	private int numPlaceholderTexts;
-	/** The internal identifier (256+), which is used to tie slides and notes together */
-	private int slideIdentifier;
-	/** Reserved fields. Who knows what they do */
-	private byte[] reservedFields;
-
-	public int getRefID() {
-		return refID;
-	}
-
-	public int getSlideIdentifier() {
-		return slideIdentifier;
-	}
-
-	public int getNumPlaceholderTexts() {
-		return numPlaceholderTexts;
-	}
-
-	public boolean getHasShapesOtherThanPlaceholders() {
-		return (flags & HAS_SHAPES_OTHER_THAN_PLACEHOLDERS) != 0;
-	}
-
-	// Only set these if you know what you're doing!
-	public void setRefID(int id) {
-		refID = id;
-	}
-	public void setSlideIdentifier(int id) {
-		slideIdentifier = id;
-	}
-
-	/* *************** record code follows ********************** */
-
-	/**
-	 * For the SlidePersist Atom
-	 */
-	protected SlidePersistAtom(byte[] source, int start, int len) {
-		// Sanity Checking
-		if(len < 8) { len = 8; }
-
-		// Get the header
-		_header = Arrays.copyOfRange(source, start, start+8);
-
-		// Grab the reference ID
-		refID = LittleEndian.getInt(source,start+8);
-
-		// Next up is a set of flags, but only bit 3 is used!
-		flags = LittleEndian.getInt(source,start+12);
-
-		// Now the number of Placeholder Texts
-		numPlaceholderTexts = LittleEndian.getInt(source,start+16);
-
-		// Last useful one is the unique slide identifier
-		slideIdentifier = LittleEndian.getInt(source,start+20);
-
-		// Finally you have typically 4 or 8 bytes of reserved fields,
-		//  all zero running from 24 bytes in to the end
-		reservedFields = IOUtils.safelyClone(source,start+24, len-24, MAX_RECORD_LENGTH);
-	}
-
-	/**
-	 * Create a new SlidePersistAtom, for use with a new Slide
-	 */
-	public SlidePersistAtom() {
-		_header = new byte[8];
-		LittleEndian.putUShort(_header, 0, 0);
-		LittleEndian.putUShort(_header, 2, (int)_type);
-		LittleEndian.putInt(_header, 4, 20);
-
-		flags = HAS_SHAPES_OTHER_THAN_PLACEHOLDERS;
-		reservedFields = new byte[4];
-	}
-
-	/**
-	 * We are of type 1011
-	 */
-	public long getRecordType() { return _type; }
-
-	/**
-	 * Write the contents of the record back, so it can be written
-	 *  to disk
-	 */
-	public void writeOut(OutputStream out) throws IOException {
-		// Header - size or type unchanged
-		out.write(_header);
-
-		// Write out our fields
-		writeLittleEndian(refID,out);
-		writeLittleEndian(flags,out);
-		writeLittleEndian(numPlaceholderTexts,out);
-		writeLittleEndian(slideIdentifier,out);
-		out.write(reservedFields);
-	}
-
-	@Override
-	public Map<String, Supplier<?>> getGenericProperties() {
-		return GenericRecordUtil.getGenericProperties(
-			"refID", this::getRefID,
-			"flags", getBitsAsString(() -> flags, FLAGS_MASKS, FLAGS_NAMES),
-			"numPlaceholderTexts", this::getNumPlaceholderTexts,
-			"slideIdentifier", this::getSlideIdentifier
-		);
-	}
+    private final byte[] _header;
+
+    /** Slide reference ID. Should correspond to the PersistPtr "sheet ID" of the matching slide/notes record */
+    private int refID;
+    private int flags;
+
+    /** Number of placeholder texts that will follow in the SlideListWithText */
+    private int numPlaceholderTexts;
+    /** The internal identifier (256+), which is used to tie slides and notes together */
+    private int slideIdentifier;
+    /** Reserved fields. Who knows what they do */
+    private byte[] reservedFields;
+
+    public int getRefID() {
+        return refID;
+    }
+
+    public int getSlideIdentifier() {
+        return slideIdentifier;
+    }
+
+    public int getNumPlaceholderTexts() {
+        return numPlaceholderTexts;
+    }
+
+    public boolean getHasShapesOtherThanPlaceholders() {
+        return (flags & HAS_SHAPES_OTHER_THAN_PLACEHOLDERS) != 0;
+    }
+
+    // Only set these if you know what you're doing!
+    public void setRefID(int id) {
+        refID = id;
+    }
+    public void setSlideIdentifier(int id) {
+        slideIdentifier = id;
+    }
+
+    /* *************** record code follows ********************** */
+
+    /**
+     * For the SlidePersist Atom
+     */
+    protected SlidePersistAtom(byte[] source, int start, int len) {
+        // Sanity Checking
+        if(len < 8) { len = 8; }
+
+        // Get the header
+        _header = Arrays.copyOfRange(source, start, start+8);
+
+        // Grab the reference ID
+        refID = LittleEndian.getInt(source,start+8);
+
+        // Next up is a set of flags, but only bit 3 is used!
+        flags = LittleEndian.getInt(source,start+12);
+
+        // Now the number of Placeholder Texts
+        numPlaceholderTexts = LittleEndian.getInt(source,start+16);
+
+        // Last useful one is the unique slide identifier
+        slideIdentifier = LittleEndian.getInt(source,start+20);
+
+        // Finally you have typically 4 or 8 bytes of reserved fields,
+        //  all zero running from 24 bytes in to the end
+        reservedFields = IOUtils.safelyClone(source,start+24, len-24, MAX_RECORD_LENGTH);
+    }
+
+    /**
+     * Create a new SlidePersistAtom, for use with a new Slide
+     */
+    public SlidePersistAtom() {
+        _header = new byte[8];
+        LittleEndian.putUShort(_header, 0, 0);
+        LittleEndian.putUShort(_header, 2, (int)_type);
+        LittleEndian.putInt(_header, 4, 20);
+
+        flags = HAS_SHAPES_OTHER_THAN_PLACEHOLDERS;
+        reservedFields = new byte[4];
+    }
+
+    /**
+     * We are of type 1011
+     */
+    public long getRecordType() { return _type; }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     *  to disk
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        // Header - size or type unchanged
+        out.write(_header);
+
+        // Write out our fields
+        writeLittleEndian(refID,out);
+        writeLittleEndian(flags,out);
+        writeLittleEndian(numPlaceholderTexts,out);
+        writeLittleEndian(slideIdentifier,out);
+        out.write(reservedFields);
+    }
+
+    @Override
+    public Map<String, Supplier<?>> getGenericProperties() {
+        return GenericRecordUtil.getGenericProperties(
+            "refID", this::getRefID,
+            "flags", getBitsAsString(() -> flags, FLAGS_MASKS, FLAGS_NAMES),
+            "numPlaceholderTexts", this::getNumPlaceholderTexts,
+            "slideIdentifier", this::getSlideIdentifier
+        );
+    }
 }

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=1890122&r1=1890121&r2=1890122&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 Sat May 22 21:37:08 2021
@@ -38,88 +38,88 @@ 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;
+    //arbitrarily selected; may need to increase
+    private static final int MAX_RECORD_LENGTH = 1_000_000;
 
-	private byte[] _header;
+    private byte[] _header;
 
-	/** The bytes that make up the text */
-	private byte[] _text;
+    /** The bytes that make up the text */
+    private byte[] _text;
 
-	/** Grabs the text. Uses the default codepage */
-	public String getText() {
-		return StringUtil.getFromCompressedUnicode(_text,0,_text.length);
-	}
-
-	/** Updates the text in the Atom. Must be 8 bit ascii */
-	public void setText(byte[] b) {
-		// Set the text
-		_text = b.clone();
-
-		// Update the size (header bytes 5-8)
-		LittleEndian.putInt(_header,4,_text.length);
-	}
-
-	/* *************** record code follows ********************** */
-
-	/**
-	 * For the TextBytes Atom
-	 */
-	protected TextBytesAtom(byte[] source, int start, int len) {
-		// Sanity Checking
-		if(len < 8) { len = 8; }
-
-		// Get the header
-		_header = Arrays.copyOfRange(source, start, start+8);
-
-		// Grab the text
-		_text = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
-	}
-
-	/**
-	 * Create an empty TextBytes Atom
-	 */
-	public TextBytesAtom() {
-		_header = new byte[8];
-		LittleEndian.putUShort(_header, 0, 0);
-		LittleEndian.putUShort(_header, 2, (int)_type);
-		LittleEndian.putInt(_header, 4, 0);
-
-		_text = new byte[]{};
-	}
-
-	/**
-	 * We are of type 4008
-	 */
-	@Override
+    /** Grabs the text. Uses the default codepage */
+    public String getText() {
+        return StringUtil.getFromCompressedUnicode(_text,0,_text.length);
+    }
+
+    /** Updates the text in the Atom. Must be 8 bit ascii */
+    public void setText(byte[] b) {
+        // Set the text
+        _text = b.clone();
+
+        // Update the size (header bytes 5-8)
+        LittleEndian.putInt(_header,4,_text.length);
+    }
+
+    /* *************** record code follows ********************** */
+
+    /**
+     * For the TextBytes Atom
+     */
+    protected TextBytesAtom(byte[] source, int start, int len) {
+        // Sanity Checking
+        if(len < 8) { len = 8; }
+
+        // Get the header
+        _header = Arrays.copyOfRange(source, start, start+8);
+
+        // Grab the text
+        _text = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+    }
+
+    /**
+     * Create an empty TextBytes Atom
+     */
+    public TextBytesAtom() {
+        _header = new byte[8];
+        LittleEndian.putUShort(_header, 0, 0);
+        LittleEndian.putUShort(_header, 2, (int)_type);
+        LittleEndian.putInt(_header, 4, 0);
+
+        _text = new byte[]{};
+    }
+
+    /**
+     * We are of type 4008
+     */
+    @Override
     public long getRecordType() { return _type; }
 
-	/**
-	 * Write the contents of the record back, so it can be written
-	 *  to disk
-	 */
-	@Override
+    /**
+     * Write the contents of the record back, so it can be written
+     *  to disk
+     */
+    @Override
     public void writeOut(OutputStream out) throws IOException {
-		// Header - size or type unchanged
-		out.write(_header);
+        // Header - size or type unchanged
+        out.write(_header);
 
-		// Write out our text
-		out.write(_text);
-	}
-
-	/**
-	 * dump debug info; use getText() to return a string
-	 * representation of the atom
-	 */
-	@Override
+        // Write out our text
+        out.write(_text);
+    }
+
+    /**
+     * dump debug info; use getText() to return a string
+     * representation of the atom
+     */
+    @Override
     public String toString() {
-		return GenericRecordJsonWriter.marshal(this);
-	}
+        return GenericRecordJsonWriter.marshal(this);
+    }
 
-	@Override
-	public Map<String, Supplier<?>> getGenericProperties() {
-		return GenericRecordUtil.getGenericProperties(
-			"text", this::getText
-		);
-	}
+    @Override
+    public Map<String, Supplier<?>> getGenericProperties() {
+        return GenericRecordUtil.getGenericProperties(
+            "text", this::getText
+        );
+    }
 }



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