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 [7/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/TextCharsAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextCharsAtom.java?rev=1890122&r1=1890121&r2=1890122&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 Sat May 22 21:37:08 2021
@@ -36,86 +36,86 @@ 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;
+    //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. */
-	public String getText() {
-		return StringUtil.getFromUnicodeLE(_text);
-	}
-
-	/** 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);
-		StringUtil.putUnicodeLE(text,_text,0);
-
-		// Update the size (header bytes 5-8)
-		LittleEndian.putInt(_header,4,_text.length);
-	}
-
-	/* *************** record code follows ********************** */
-
-	/**
-	 * For the TextChars Atom
-	 */
-	protected TextCharsAtom(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 TextCharsAtom
-	 */
-	public TextCharsAtom() {
-		// 0 length header
-		_header = new byte[] {  0, 0, 0xA0-256, 0x0f, 0, 0, 0, 0 };
-		// Empty text
-		_text = new byte[0];
-	}
-
-	/**
-	 * We are of type 4000
-	 */
-	@Override
+    /** Grabs the text. */
+    public String getText() {
+        return StringUtil.getFromUnicodeLE(_text);
+    }
+
+    /** 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);
+        StringUtil.putUnicodeLE(text,_text,0);
+
+        // Update the size (header bytes 5-8)
+        LittleEndian.putInt(_header,4,_text.length);
+    }
+
+    /* *************** record code follows ********************** */
+
+    /**
+     * For the TextChars Atom
+     */
+    protected TextCharsAtom(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 TextCharsAtom
+     */
+    public TextCharsAtom() {
+        // 0 length header
+        _header = new byte[] {  0, 0, 0xA0-256, 0x0f, 0, 0, 0, 0 };
+        // Empty text
+        _text = new byte[0];
+    }
+
+    /**
+     * We are of type 4000
+     */
+    @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
+        );
+    }
 }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextHeaderAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextHeaderAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextHeaderAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextHeaderAtom.java Sat May 22 21:37:08 2021
@@ -36,97 +36,97 @@ import org.apache.poi.util.LittleEndian;
 
 public final class TextHeaderAtom extends RecordAtom implements ParentAwareRecord {
     public static final long _type = RecordTypes.TextHeaderAtom.typeID;
-	private byte[] _header;
-	private org.apache.poi.hslf.record.RecordContainer parentRecord;
+    private byte[] _header;
+    private org.apache.poi.hslf.record.RecordContainer parentRecord;
 
-	/** The kind of text it is */
-	private int textType;
-	/** position in the owning SlideListWithText */
-	private int index = -1;
-
-	public int getTextType() { return textType; }
-	public void setTextType(int type) { textType = type; }
-
-	public TextPlaceholder getTextTypeEnum() {
-		return TextPlaceholder.fromNativeId(textType);
-	}
-
-	public void setTextTypeEnum(TextPlaceholder placeholder) {
-		textType = placeholder.nativeId;
-	}
+    /** The kind of text it is */
+    private int textType;
+    /** position in the owning SlideListWithText */
+    private int index = -1;
+
+    public int getTextType() { return textType; }
+    public void setTextType(int type) { textType = type; }
+
+    public TextPlaceholder getTextTypeEnum() {
+        return TextPlaceholder.fromNativeId(textType);
+    }
+
+    public void setTextTypeEnum(TextPlaceholder placeholder) {
+        textType = placeholder.nativeId;
+    }
 
     /**
      * @return  0-based index of the text run in the SLWT container
      */
-	public int getIndex() { return index; }
+    public int getIndex() { return index; }
 
     /**
      *  @param index 0-based index of the text run in the SLWT container
      */
-	public void setIndex(int index) { this.index = index; }
+    public void setIndex(int index) { this.index = index; }
 
-	@Override
+    @Override
     public org.apache.poi.hslf.record.RecordContainer getParentRecord() { return parentRecord; }
-	@Override
+    @Override
     public void setParentRecord(RecordContainer record) { this.parentRecord = record; }
 
-	/* *************** record code follows ********************** */
+    /* *************** record code follows ********************** */
 
-	/**
-	 * For the TextHeader Atom
-	 */
-	protected TextHeaderAtom(byte[] source, int start, int len) {
-		// Sanity Checking - we're always 12 bytes long
-		if(len < 12) {
-			len = 12;
-			if(source.length - start < 12) {
-				throw new HSLFException("Not enough data to form a TextHeaderAtom (always 12 bytes long) - found " + (source.length - start));
-			}
-		}
-
-		// Get the header
-		_header = Arrays.copyOfRange(source, start, start+8);
-
-		// Grab the type
-		textType = LittleEndian.getInt(source,start+8);
-	}
-
-	/**
-	 * Create a new TextHeader Atom, for an unknown type of text
-	 */
-	public TextHeaderAtom() {
-		_header = new byte[8];
-		LittleEndian.putUShort(_header, 0, 0);
-		LittleEndian.putUShort(_header, 2, (int)_type);
-		LittleEndian.putInt(_header, 4, 4);
-
-		textType = TextPlaceholder.OTHER.nativeId;
-	}
-
-	/**
-	 * We are of type 3999
-	 */
-	@Override
+    /**
+     * For the TextHeader Atom
+     */
+    protected TextHeaderAtom(byte[] source, int start, int len) {
+        // Sanity Checking - we're always 12 bytes long
+        if(len < 12) {
+            len = 12;
+            if(source.length - start < 12) {
+                throw new HSLFException("Not enough data to form a TextHeaderAtom (always 12 bytes long) - found " + (source.length - start));
+            }
+        }
+
+        // Get the header
+        _header = Arrays.copyOfRange(source, start, start+8);
+
+        // Grab the type
+        textType = LittleEndian.getInt(source,start+8);
+    }
+
+    /**
+     * Create a new TextHeader Atom, for an unknown type of text
+     */
+    public TextHeaderAtom() {
+        _header = new byte[8];
+        LittleEndian.putUShort(_header, 0, 0);
+        LittleEndian.putUShort(_header, 2, (int)_type);
+        LittleEndian.putInt(_header, 4, 4);
+
+        textType = TextPlaceholder.OTHER.nativeId;
+    }
+
+    /**
+     * We are of type 3999
+     */
+    @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 type
-		writeLittleEndian(textType,out);
-	}
-
-	@Override
-	public Map<String, Supplier<?>> getGenericProperties() {
-		return GenericRecordUtil.getGenericProperties(
-			"index", this::getIndex,
-			"textType", this::getTextTypeEnum
-		);
-	}
+        // Write out our type
+        writeLittleEndian(textType,out);
+    }
+
+    @Override
+    public Map<String, Supplier<?>> getGenericProperties() {
+        return GenericRecordUtil.getGenericProperties(
+            "index", this::getIndex,
+            "textType", this::getTextTypeEnum
+        );
+    }
 }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java Sat May 22 21:37:08 2021
@@ -36,49 +36,49 @@ import org.apache.poi.util.LittleEndian;
 public final class UnknownRecordPlaceholder extends RecordAtom
 {
 
-	//arbitrarily selected; may need to increase
-	private static final int MAX_RECORD_LENGTH = 20_000_000;
+    //arbitrarily selected; may need to increase
+    private static final int MAX_RECORD_LENGTH = 20_000_000;
 
-	private byte[] _contents;
-	private long _type;
+    private byte[] _contents;
+    private long _type;
 
-	/**
-	 * Create a new holder for a record we don't grok
-	 */
-	protected UnknownRecordPlaceholder(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 < 0) { len = 0; }
-
-		// Treat as an atom, grab and hold everything
-		_contents = IOUtils.safelyClone(source, start, len, MAX_RECORD_LENGTH);
-		_type = LittleEndian.getUShort(_contents,2);
-	}
-
-	/**
-	 * Return the value we were given at creation
-	 */
-	public long getRecordType() {
-		return _type;
-	}
-
-	/**
-	 * Return the value as enum we were given at creation
-	 */
-	public org.apache.poi.hslf.record.RecordTypes getRecordTypeEnum() {
-		return RecordTypes.forTypeID((int)_type);
-	}
-
-	/**
-	 * Write the contents of the record back, so it can be written
-	 *  to disk
-	 */
-	public void writeOut(OutputStream out) throws IOException {
-		out.write(_contents);
-	}
-
-	@Override
-	public Map<String, Supplier<?>> getGenericProperties() {
-		return GenericRecordUtil.getGenericProperties("contents", () -> _contents);
-	}
+    /**
+     * Create a new holder for a record we don't grok
+     */
+    protected UnknownRecordPlaceholder(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 < 0) { len = 0; }
+
+        // Treat as an atom, grab and hold everything
+        _contents = IOUtils.safelyClone(source, start, len, MAX_RECORD_LENGTH);
+        _type = LittleEndian.getUShort(_contents,2);
+    }
+
+    /**
+     * Return the value we were given at creation
+     */
+    public long getRecordType() {
+        return _type;
+    }
+
+    /**
+     * Return the value as enum we were given at creation
+     */
+    public org.apache.poi.hslf.record.RecordTypes getRecordTypeEnum() {
+        return RecordTypes.forTypeID((int)_type);
+    }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     *  to disk
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        out.write(_contents);
+    }
+
+    @Override
+    public Map<String, Supplier<?>> getGenericProperties() {
+        return GenericRecordUtil.getGenericProperties("contents", () -> _contents);
+    }
 }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/UserEditAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/UserEditAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/UserEditAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/UserEditAtom.java Sat May 22 21:37:08 2021
@@ -40,169 +40,169 @@ import org.apache.poi.util.LittleEndianC
 
 public final class UserEditAtom extends PositionDependentRecordAtom
 {
-	public static final int LAST_VIEW_NONE = 0;
-	public static final int LAST_VIEW_SLIDE_VIEW = 1;
-	public static final int LAST_VIEW_OUTLINE_VIEW = 2;
-	public static final int LAST_VIEW_NOTES = 3;
-
-	private byte[] _header;
-	private static final long _type = RecordTypes.UserEditAtom.typeID;
-	private short unused;
-
-	private int lastViewedSlideID;
-	private int pptVersion;
-	private int lastUserEditAtomOffset;
-	private int persistPointersOffset;
-	private int docPersistRef;
-	private int maxPersistWritten;
-	private short lastViewType;
-	private int encryptSessionPersistIdRef = -1;
-
-	// Somewhat user facing getters
-	public int getLastViewedSlideID() { return lastViewedSlideID; }
-	public short getLastViewType()    { return lastViewType; }
-
-	// Scary internal getters
-	public int getLastUserEditAtomOffset() { return lastUserEditAtomOffset; }
-	public int getPersistPointersOffset()  { return persistPointersOffset; }
-	public int getDocPersistRef()          { return docPersistRef; }
-	public int getMaxPersistWritten()      { return maxPersistWritten; }
-	public int getEncryptSessionPersistIdRef() { return encryptSessionPersistIdRef; }
-
-	// More scary internal setters
-	public void setLastUserEditAtomOffset(int offset) { lastUserEditAtomOffset = offset; }
-	public void setPersistPointersOffset(int offset)  { persistPointersOffset = offset; }
-	public void setLastViewType(short type)           { lastViewType=type; }
+    public static final int LAST_VIEW_NONE = 0;
+    public static final int LAST_VIEW_SLIDE_VIEW = 1;
+    public static final int LAST_VIEW_OUTLINE_VIEW = 2;
+    public static final int LAST_VIEW_NOTES = 3;
+
+    private byte[] _header;
+    private static final long _type = RecordTypes.UserEditAtom.typeID;
+    private short unused;
+
+    private int lastViewedSlideID;
+    private int pptVersion;
+    private int lastUserEditAtomOffset;
+    private int persistPointersOffset;
+    private int docPersistRef;
+    private int maxPersistWritten;
+    private short lastViewType;
+    private int encryptSessionPersistIdRef = -1;
+
+    // Somewhat user facing getters
+    public int getLastViewedSlideID() { return lastViewedSlideID; }
+    public short getLastViewType()    { return lastViewType; }
+
+    // Scary internal getters
+    public int getLastUserEditAtomOffset() { return lastUserEditAtomOffset; }
+    public int getPersistPointersOffset()  { return persistPointersOffset; }
+    public int getDocPersistRef()          { return docPersistRef; }
+    public int getMaxPersistWritten()      { return maxPersistWritten; }
+    public int getEncryptSessionPersistIdRef() { return encryptSessionPersistIdRef; }
+
+    // More scary internal setters
+    public void setLastUserEditAtomOffset(int offset) { lastUserEditAtomOffset = offset; }
+    public void setPersistPointersOffset(int offset)  { persistPointersOffset = offset; }
+    public void setLastViewType(short type)           { lastViewType=type; }
     public void setMaxPersistWritten(int max)         { maxPersistWritten=max; }
     public void setEncryptSessionPersistIdRef(int id) {
         encryptSessionPersistIdRef=id;
         LittleEndian.putInt(_header,4,(id == -1 ? 28 : 32));
     }
 
-	/* *************** record code follows ********************** */
+    /* *************** record code follows ********************** */
 
-	/**
-	 * For the UserEdit Atom
-	 */
-	protected UserEditAtom(byte[] source, int start, int len) {
-		// Sanity Checking
-		if(len < 34) { len = 34; }
-
-		int offset = start;
-		// Get the header
-		_header = Arrays.copyOfRange(source, start, start+8);
-		offset += 8;
-
-		// Get the last viewed slide ID
-		lastViewedSlideID = LittleEndian.getInt(source,offset);
-		offset += LittleEndianConsts.INT_SIZE;
-
-		// Get the PPT version
-		pptVersion = LittleEndian.getInt(source,offset);
-		offset += LittleEndianConsts.INT_SIZE;
-
-		// Get the offset to the previous incremental save's UserEditAtom
-		// This will be the byte offset on disk where the previous one
-		//  starts, or 0 if this is the first one
-		lastUserEditAtomOffset = LittleEndian.getInt(source,offset);
-		offset += LittleEndianConsts.INT_SIZE;
-
-		// Get the offset to the persist pointers
-		// This will be the byte offset on disk where the preceding
-		//  PersistPtrFullBlock or PersistPtrIncrementalBlock starts
-		persistPointersOffset = LittleEndian.getInt(source,offset);
-		offset += LittleEndianConsts.INT_SIZE;
-
-		// Get the persist reference for the document persist object
-		// Normally seems to be 1
-		docPersistRef = LittleEndian.getInt(source,offset);
-		offset += LittleEndianConsts.INT_SIZE;
-
-		// Maximum number of persist objects written
-		maxPersistWritten = LittleEndian.getInt(source,offset);
-		offset += LittleEndianConsts.INT_SIZE;
-
-		// Last view type
-		lastViewType = LittleEndian.getShort(source,offset);
-		offset += LittleEndianConsts.SHORT_SIZE;
-
-		// unused
-		unused = LittleEndian.getShort(source,offset);
-		offset += LittleEndianConsts.SHORT_SIZE;
-
-		// There might be a few more bytes, which are a reserved field
-		if (offset-start<len) {
-		    encryptSessionPersistIdRef = LittleEndian.getInt(source,offset);
-		    offset += LittleEndianConsts.INT_SIZE;
-		}
-
-		assert(offset-start == len);
-	}
-
-	/**
-	 * We are of type 4085
-	 */
-	@Override
+    /**
+     * For the UserEdit Atom
+     */
+    protected UserEditAtom(byte[] source, int start, int len) {
+        // Sanity Checking
+        if(len < 34) { len = 34; }
+
+        int offset = start;
+        // Get the header
+        _header = Arrays.copyOfRange(source, start, start+8);
+        offset += 8;
+
+        // Get the last viewed slide ID
+        lastViewedSlideID = LittleEndian.getInt(source,offset);
+        offset += LittleEndianConsts.INT_SIZE;
+
+        // Get the PPT version
+        pptVersion = LittleEndian.getInt(source,offset);
+        offset += LittleEndianConsts.INT_SIZE;
+
+        // Get the offset to the previous incremental save's UserEditAtom
+        // This will be the byte offset on disk where the previous one
+        //  starts, or 0 if this is the first one
+        lastUserEditAtomOffset = LittleEndian.getInt(source,offset);
+        offset += LittleEndianConsts.INT_SIZE;
+
+        // Get the offset to the persist pointers
+        // This will be the byte offset on disk where the preceding
+        //  PersistPtrFullBlock or PersistPtrIncrementalBlock starts
+        persistPointersOffset = LittleEndian.getInt(source,offset);
+        offset += LittleEndianConsts.INT_SIZE;
+
+        // Get the persist reference for the document persist object
+        // Normally seems to be 1
+        docPersistRef = LittleEndian.getInt(source,offset);
+        offset += LittleEndianConsts.INT_SIZE;
+
+        // Maximum number of persist objects written
+        maxPersistWritten = LittleEndian.getInt(source,offset);
+        offset += LittleEndianConsts.INT_SIZE;
+
+        // Last view type
+        lastViewType = LittleEndian.getShort(source,offset);
+        offset += LittleEndianConsts.SHORT_SIZE;
+
+        // unused
+        unused = LittleEndian.getShort(source,offset);
+        offset += LittleEndianConsts.SHORT_SIZE;
+
+        // There might be a few more bytes, which are a reserved field
+        if (offset-start<len) {
+            encryptSessionPersistIdRef = LittleEndian.getInt(source,offset);
+            offset += LittleEndianConsts.INT_SIZE;
+        }
+
+        assert(offset-start == len);
+    }
+
+    /**
+     * We are of type 4085
+     */
+    @Override
     public long getRecordType() { return _type; }
 
-	/**
-	 * At write-out time, update the references to PersistPtrs and
-	 *  other UserEditAtoms to point to their new positions
-	 */
-	@Override
+    /**
+     * At write-out time, update the references to PersistPtrs and
+     *  other UserEditAtoms to point to their new positions
+     */
+    @Override
     public void updateOtherRecordReferences(Map<Integer,Integer> oldToNewReferencesLookup) {
-		// Look up the new positions of our preceding UserEditAtomOffset
-		if(lastUserEditAtomOffset != 0) {
-			Integer newLocation = oldToNewReferencesLookup.get(Integer.valueOf(lastUserEditAtomOffset));
-			if(newLocation == null) {
-				throw new HSLFException("Couldn't find the new location of the UserEditAtom that used to be at " + lastUserEditAtomOffset);
-			}
-			lastUserEditAtomOffset = newLocation.intValue();
-		}
-
-		// Ditto for our PersistPtr
-		Integer newLocation = oldToNewReferencesLookup.get(Integer.valueOf(persistPointersOffset));
-		if(newLocation == null) {
-			throw new HSLFException("Couldn't find the new location of the PersistPtr that used to be at " + persistPointersOffset);
-		}
-		persistPointersOffset = newLocation.intValue();
-	}
-
-	/**
-	 * Write the contents of the record back, so it can be written
-	 *  to disk
-	 */
-	@Override
+        // Look up the new positions of our preceding UserEditAtomOffset
+        if(lastUserEditAtomOffset != 0) {
+            Integer newLocation = oldToNewReferencesLookup.get(Integer.valueOf(lastUserEditAtomOffset));
+            if(newLocation == null) {
+                throw new HSLFException("Couldn't find the new location of the UserEditAtom that used to be at " + lastUserEditAtomOffset);
+            }
+            lastUserEditAtomOffset = newLocation.intValue();
+        }
+
+        // Ditto for our PersistPtr
+        Integer newLocation = oldToNewReferencesLookup.get(Integer.valueOf(persistPointersOffset));
+        if(newLocation == null) {
+            throw new HSLFException("Couldn't find the new location of the PersistPtr that used to be at " + persistPointersOffset);
+        }
+        persistPointersOffset = newLocation.intValue();
+    }
+
+    /**
+     * 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);
+
+        // Write out the values
+        writeLittleEndian(lastViewedSlideID,out);
+        writeLittleEndian(pptVersion,out);
+        writeLittleEndian(lastUserEditAtomOffset,out);
+        writeLittleEndian(persistPointersOffset,out);
+        writeLittleEndian(docPersistRef,out);
+        writeLittleEndian(maxPersistWritten,out);
+        writeLittleEndian(lastViewType,out);
+        writeLittleEndian(unused,out);
+        if (encryptSessionPersistIdRef != -1) {
+            // optional field
+            writeLittleEndian(encryptSessionPersistIdRef,out);
+        }
+    }
 
-		// Write out the values
-		writeLittleEndian(lastViewedSlideID,out);
-		writeLittleEndian(pptVersion,out);
-		writeLittleEndian(lastUserEditAtomOffset,out);
-		writeLittleEndian(persistPointersOffset,out);
-		writeLittleEndian(docPersistRef,out);
-		writeLittleEndian(maxPersistWritten,out);
-		writeLittleEndian(lastViewType,out);
-		writeLittleEndian(unused,out);
-		if (encryptSessionPersistIdRef != -1) {
-		    // optional field
-		    writeLittleEndian(encryptSessionPersistIdRef,out);
-		}
-	}
-
-	@Override
-	public Map<String, Supplier<?>> getGenericProperties() {
-		final Map<String, Supplier<?>> m = new LinkedHashMap<>();
-		m.put("lastViewedSlideID", this::getLastViewedSlideID);
-		m.put("pptVersion", () -> pptVersion);
-		m.put("lastUserEditAtomOffset", this::getLastUserEditAtomOffset);
-		m.put("persistPointersOffset", this::getPersistPointersOffset);
-		m.put("docPersistRef", this::getDocPersistRef);
-		m.put("maxPersistWritten", this::getMaxPersistWritten);
-		m.put("lastViewType", this::getLastViewType);
-		m.put("encryptSessionPersistIdRef", this::getEncryptSessionPersistIdRef);
-		return Collections.unmodifiableMap(m);
-	}
+    @Override
+    public Map<String, Supplier<?>> getGenericProperties() {
+        final Map<String, Supplier<?>> m = new LinkedHashMap<>();
+        m.put("lastViewedSlideID", this::getLastViewedSlideID);
+        m.put("pptVersion", () -> pptVersion);
+        m.put("lastUserEditAtomOffset", this::getLastUserEditAtomOffset);
+        m.put("persistPointersOffset", this::getPersistPointersOffset);
+        m.put("docPersistRef", this::getDocPersistRef);
+        m.put("maxPersistWritten", this::getMaxPersistWritten);
+        m.put("lastViewType", this::getLastViewType);
+        m.put("encryptSessionPersistIdRef", this::getEncryptSessionPersistIdRef);
+        return Collections.unmodifiableMap(m);
+    }
 }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFObjectShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFObjectShape.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFObjectShape.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFObjectShape.java Sat May 22 21:37:08 2021
@@ -97,14 +97,14 @@ public final class HSLFObjectShape exten
      * @param objectId the unique identifier for the OLE object
      */
     public void setObjectID(int objectId){
-    	setEscherProperty(EscherPropertyTypes.BLIP__PICTUREID, objectId);
+        setEscherProperty(EscherPropertyTypes.BLIP__PICTUREID, objectId);
 
-    	EscherContainerRecord ecr = getSpContainer();
-    	EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID);
-    	if (spRecord != null) {
+        EscherContainerRecord ecr = getSpContainer();
+        EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID);
+        if (spRecord != null) {
             spRecord.setFlags(spRecord.getFlags() | EscherSpRecord.FLAG_OLESHAPE);
         } else {
-    	    LOG.atWarn().log("Ole shape record not found.");
+            LOG.atWarn().log("Ole shape record not found.");
         }
 
         HSLFEscherClientDataRecord cldata = getClientData(true);
@@ -116,8 +116,8 @@ public final class HSLFObjectShape exten
             }
         }
         if (uer == null) {
-        	uer = new ExObjRefAtom();
-        	cldata.addChild(uer);
+            uer = new ExObjRefAtom();
+            cldata.addChild(uer);
         }
         uer.setExObjIdRef(objectId);
     }

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlide.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlide.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlide.java Sat May 22 21:37:08 2021
@@ -56,56 +56,56 @@ import org.apache.poi.sl.usermodel.TextS
  */
 
 public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFTextParagraph> {
-	private int _slideNo;
-	private SlideAtomsSet _atomSet;
-	private final List<List<HSLFTextParagraph>> _paragraphs = new ArrayList<>();
-	private HSLFNotes _notes; // usermodel needs to set this
-
-	/**
-	 * Constructs a Slide from the Slide record, and the SlideAtomsSet
-	 *  containing the text.
-	 * Initializes TextRuns, to provide easier access to the text
-	 *
-	 * @param slide the Slide record we're based on
-	 * @param notes the Notes sheet attached to us
-	 * @param atomSet the SlideAtomsSet to get the text from
-	 */
-	public HSLFSlide(org.apache.poi.hslf.record.Slide slide, HSLFNotes notes, SlideAtomsSet atomSet, int slideIdentifier, int slideNumber) {
+    private int _slideNo;
+    private SlideAtomsSet _atomSet;
+    private final List<List<HSLFTextParagraph>> _paragraphs = new ArrayList<>();
+    private HSLFNotes _notes; // usermodel needs to set this
+
+    /**
+     * Constructs a Slide from the Slide record, and the SlideAtomsSet
+     *  containing the text.
+     * Initializes TextRuns, to provide easier access to the text
+     *
+     * @param slide the Slide record we're based on
+     * @param notes the Notes sheet attached to us
+     * @param atomSet the SlideAtomsSet to get the text from
+     */
+    public HSLFSlide(org.apache.poi.hslf.record.Slide slide, HSLFNotes notes, SlideAtomsSet atomSet, int slideIdentifier, int slideNumber) {
         super(slide, slideIdentifier);
 
-		_notes = notes;
-		_atomSet = atomSet;
-		_slideNo = slideNumber;
-
-		// For the text coming in from the SlideAtomsSet:
-		// Build up TextRuns from pairs of TextHeaderAtom and
-		//  one of TextBytesAtom or TextCharsAtom
-		if (_atomSet != null && _atomSet.getSlideRecords().length > 0) {
-		    // Grab text from SlideListWithTexts entries
-		    _paragraphs.addAll(HSLFTextParagraph.findTextParagraphs(_atomSet.getSlideRecords()));
-	        if (_paragraphs.isEmpty()) {
-	            throw new HSLFException("No text records found for slide");
-	        }
-		}
-
-		// Grab text from slide's PPDrawing
-		for (List<HSLFTextParagraph> l : HSLFTextParagraph.findTextParagraphs(getPPDrawing(), this)) {
-		    if (!_paragraphs.contains(l)) {
+        _notes = notes;
+        _atomSet = atomSet;
+        _slideNo = slideNumber;
+
+        // For the text coming in from the SlideAtomsSet:
+        // Build up TextRuns from pairs of TextHeaderAtom and
+        //  one of TextBytesAtom or TextCharsAtom
+        if (_atomSet != null && _atomSet.getSlideRecords().length > 0) {
+            // Grab text from SlideListWithTexts entries
+            _paragraphs.addAll(HSLFTextParagraph.findTextParagraphs(_atomSet.getSlideRecords()));
+            if (_paragraphs.isEmpty()) {
+                throw new HSLFException("No text records found for slide");
+            }
+        }
+
+        // Grab text from slide's PPDrawing
+        for (List<HSLFTextParagraph> l : HSLFTextParagraph.findTextParagraphs(getPPDrawing(), this)) {
+            if (!_paragraphs.contains(l)) {
                 _paragraphs.add(l);
             }
-		}
-	}
+        }
+    }
 
-	/**
-	* Create a new Slide instance
-	* @param sheetNumber The internal number of the sheet, as used by PersistPtrHolder
-	* @param slideNumber The user facing number of the sheet
-	*/
-	public HSLFSlide(int sheetNumber, int sheetRefId, int slideNumber){
-		super(new org.apache.poi.hslf.record.Slide(), sheetNumber);
-		_slideNo = slideNumber;
+    /**
+    * Create a new Slide instance
+    * @param sheetNumber The internal number of the sheet, as used by PersistPtrHolder
+    * @param slideNumber The user facing number of the sheet
+    */
+    public HSLFSlide(int sheetNumber, int sheetRefId, int slideNumber){
+        super(new org.apache.poi.hslf.record.Slide(), sheetNumber);
+        _slideNo = slideNumber;
         getSheetContainer().setSheetId(sheetRefId);
-	}
+    }
 
     /**
      * Returns the Notes Sheet for this slide, or null if there isn't one
@@ -115,36 +115,36 @@ public final class HSLFSlide extends HSL
         return _notes;
     }
 
-	/**
-	 * Sets the Notes that are associated with this. Updates the
-	 *  references in the records to point to the new ID
-	 */
-	@Override
-	public void setNotes(Notes<HSLFShape,HSLFTextParagraph> notes) {
+    /**
+     * Sets the Notes that are associated with this. Updates the
+     *  references in the records to point to the new ID
+     */
+    @Override
+    public void setNotes(Notes<HSLFShape,HSLFTextParagraph> notes) {
         if (notes != null && !(notes instanceof HSLFNotes)) {
             throw new IllegalArgumentException("notes needs to be of type HSLFNotes");
         }
-		_notes = (HSLFNotes)notes;
+        _notes = (HSLFNotes)notes;
 
-		// Update the Slide Atom's ID of where to point to
-		SlideAtom sa = getSlideRecord().getSlideAtom();
+        // Update the Slide Atom's ID of where to point to
+        SlideAtom sa = getSlideRecord().getSlideAtom();
 
-		if(_notes == null) {
-			// Set to 0
-			sa.setNotesID(0);
-		} else {
-			// Set to the value from the notes' sheet id
-			sa.setNotesID(_notes._getSheetNumber());
-		}
-	}
-
-	/**
-	* Changes the Slide's (external facing) page number.
-	* @see org.apache.poi.hslf.usermodel.HSLFSlideShow#reorderSlide(int, int)
-	*/
-	public void setSlideNumber(int newSlideNumber) {
-		_slideNo = newSlideNumber;
-	}
+        if(_notes == null) {
+            // Set to 0
+            sa.setNotesID(0);
+        } else {
+            // Set to the value from the notes' sheet id
+            sa.setNotesID(_notes._getSheetNumber());
+        }
+    }
+
+    /**
+    * Changes the Slide's (external facing) page number.
+    * @see org.apache.poi.hslf.usermodel.HSLFSlideShow#reorderSlide(int, int)
+    */
+    public void setSlideNumber(int newSlideNumber) {
+        _slideNo = newSlideNumber;
+    }
 
     /**
      * Called by SlideShow ater a new slide is created.
@@ -187,79 +187,79 @@ public final class HSLFSlide extends HSL
         dg.setNumShapes(1);
     }
 
-	/**
-	 * Create a {@code TextBox} object that represents the slide's title.
-	 *
-	 * @return {@code TextBox} object that represents the slide's title.
-	 */
-	public HSLFTextBox addTitle() {
-		HSLFPlaceholder pl = new HSLFPlaceholder();
-		pl.setShapeType(ShapeType.RECT);
-		pl.setPlaceholder(Placeholder.TITLE);
-		pl.setRunType(TextPlaceholder.TITLE.nativeId);
-		pl.setText("Click to edit title");
-		pl.setAnchor(new java.awt.Rectangle(54, 48, 612, 90));
-		addShape(pl);
-		return pl;
-	}
-
-
-	// Complex Accesser methods follow
-
-	/**
-	 * <p>
-	 * The title is a run of text of type {@code TextHeaderAtom.CENTER_TITLE_TYPE} or
-	 * {@code TextHeaderAtom.TITLE_TYPE}
-	 * </p>
-	 *
-	 * @see TextHeaderAtom
-	 */
-	@Override
-	public String getTitle(){
-		for (List<HSLFTextParagraph> tp : getTextParagraphs()) {
-		    if (tp.isEmpty()) {
+    /**
+     * Create a {@code TextBox} object that represents the slide's title.
+     *
+     * @return {@code TextBox} object that represents the slide's title.
+     */
+    public HSLFTextBox addTitle() {
+        HSLFPlaceholder pl = new HSLFPlaceholder();
+        pl.setShapeType(ShapeType.RECT);
+        pl.setPlaceholder(Placeholder.TITLE);
+        pl.setRunType(TextPlaceholder.TITLE.nativeId);
+        pl.setText("Click to edit title");
+        pl.setAnchor(new java.awt.Rectangle(54, 48, 612, 90));
+        addShape(pl);
+        return pl;
+    }
+
+
+    // Complex Accesser methods follow
+
+    /**
+     * <p>
+     * The title is a run of text of type {@code TextHeaderAtom.CENTER_TITLE_TYPE} or
+     * {@code TextHeaderAtom.TITLE_TYPE}
+     * </p>
+     *
+     * @see TextHeaderAtom
+     */
+    @Override
+    public String getTitle(){
+        for (List<HSLFTextParagraph> tp : getTextParagraphs()) {
+            if (tp.isEmpty()) {
                 continue;
             }
-			int type = tp.get(0).getRunType();
-		    if (TextPlaceholder.isTitle(type)) {
+            int type = tp.get(0).getRunType();
+            if (TextPlaceholder.isTitle(type)) {
                 String str = HSLFTextParagraph.getRawText(tp);
                 return HSLFTextParagraph.toExternalString(str, type);
             }
-		}
-		return null;
-	}
+        }
+        return null;
+    }
 
     @Override
-	public String getSlideName() {
+    public String getSlideName() {
         final CString name = (CString)getSlideRecord().findFirstOfType(RecordTypes.CString.typeID);
         return name != null ? name.getText() : "Slide"+getSlideNumber();
     }
 
 
-	/**
-	 * Returns an array of all the TextRuns found
-	 */
-	@Override
+    /**
+     * Returns an array of all the TextRuns found
+     */
+    @Override
     public List<List<HSLFTextParagraph>> getTextParagraphs() { return _paragraphs; }
 
-	/**
-	 * Returns the (public facing) page number of this slide
-	 */
-	@Override
-	public int getSlideNumber() { return _slideNo; }
-
-	/**
-	 * Returns the underlying slide record
-	 */
-	public org.apache.poi.hslf.record.Slide getSlideRecord() {
+    /**
+     * Returns the (public facing) page number of this slide
+     */
+    @Override
+    public int getSlideNumber() { return _slideNo; }
+
+    /**
+     * Returns the underlying slide record
+     */
+    public org.apache.poi.hslf.record.Slide getSlideRecord() {
         return (org.apache.poi.hslf.record.Slide)getSheetContainer();
     }
 
-	/**
-	 * @return set of records inside {@code SlideListWithtext} container
-	 *  which hold text data for this slide (typically for placeholders).
-	 */
-	protected SlideAtomsSet getSlideAtomsSet() { return _atomSet;  }
+    /**
+     * @return set of records inside {@code SlideListWithtext} container
+     *  which hold text data for this slide (typically for placeholders).
+     */
+    protected SlideAtomsSet getSlideAtomsSet() { return _atomSet;  }
 
     /**
      * Returns master sheet associated with this slide.
@@ -403,8 +403,8 @@ public final class HSLFSlide extends HSL
     @Override
     public List<HSLFComment> getComments() {
         final List<HSLFComment> comments = new ArrayList<>();
-    	// If there are any, they're in
-    	//  ProgTags -> ProgBinaryTag -> BinaryTagData
+        // If there are any, they're in
+        //  ProgTags -> ProgBinaryTag -> BinaryTagData
         final RecordContainer binaryTags =
                 selectContainer(getSheetContainer(), 0,
                         RecordTypes.ProgTags, RecordTypes.ProgBinaryTag, RecordTypes.BinaryTagData);
@@ -417,7 +417,7 @@ public final class HSLFSlide extends HSL
             }
         }
 
-    	return comments;
+        return comments;
     }
 
     /**
@@ -438,33 +438,33 @@ public final class HSLFSlide extends HSL
 
     /** This will return an atom per TextBox, so if the page has two text boxes the method should return two atoms. */
     public StyleTextProp9Atom[] getNumberedListInfo() {
-    	return this.getPPDrawing().getNumberedListInfo();
+        return this.getPPDrawing().getNumberedListInfo();
     }
 
-	public EscherTextboxWrapper[] getTextboxWrappers() {
-		return this.getPPDrawing().getTextboxWrappers();
-	}
+    public EscherTextboxWrapper[] getTextboxWrappers() {
+        return this.getPPDrawing().getTextboxWrappers();
+    }
 
-	@Override
-	public void setHidden(boolean hidden) {
-		org.apache.poi.hslf.record.Slide cont =	getSlideRecord();
+    @Override
+    public void setHidden(boolean hidden) {
+        org.apache.poi.hslf.record.Slide cont = getSlideRecord();
 
-		SSSlideInfoAtom slideInfo =
-			(SSSlideInfoAtom)cont.findFirstOfType(RecordTypes.SSSlideInfoAtom.typeID);
-		if (slideInfo == null) {
-			slideInfo = new SSSlideInfoAtom();
-			cont.addChildAfter(slideInfo, cont.findFirstOfType(RecordTypes.SlideAtom.typeID));
-		}
+        SSSlideInfoAtom slideInfo =
+            (SSSlideInfoAtom)cont.findFirstOfType(RecordTypes.SSSlideInfoAtom.typeID);
+        if (slideInfo == null) {
+            slideInfo = new SSSlideInfoAtom();
+            cont.addChildAfter(slideInfo, cont.findFirstOfType(RecordTypes.SlideAtom.typeID));
+        }
 
-		slideInfo.setEffectTransitionFlagByBit(SSSlideInfoAtom.HIDDEN_BIT, hidden);
-	}
+        slideInfo.setEffectTransitionFlagByBit(SSSlideInfoAtom.HIDDEN_BIT, hidden);
+    }
 
     @Override
-	public boolean isHidden() {
-		SSSlideInfoAtom slideInfo =
-			(SSSlideInfoAtom)getSlideRecord().findFirstOfType(RecordTypes.SSSlideInfoAtom.typeID);
-		return (slideInfo != null) && slideInfo.getEffectTransitionFlagByBit(SSSlideInfoAtom.HIDDEN_BIT);
-	}
+    public boolean isHidden() {
+        SSSlideInfoAtom slideInfo =
+            (SSSlideInfoAtom)getSlideRecord().findFirstOfType(RecordTypes.SSSlideInfoAtom.typeID);
+        return (slideInfo != null) && slideInfo.getEffectTransitionFlagByBit(SSSlideInfoAtom.HIDDEN_BIT);
+    }
 
     @Override
     public void draw(Graphics2D graphics) {



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