FileDocCategorySizeDatePackage
UserEditAtom.javaAPI DocApache Poi 3.0.15941Mon Jan 01 18:55:34 GMT 2007org.apache.poi.hslf.record

UserEditAtom

public class UserEditAtom extends PositionDependentRecordAtom
A UserEdit Atom (type 4085). Holds information which bits of the file were last used by powerpoint, the version of powerpoint last used etc. ** WARNING ** stores byte offsets from the start of the PPT stream to other records! If you change the size of any elements before one of these, you'll need to update the offsets!
author
Nick Burch

Fields Summary
public static final int
LAST_VIEW_NONE
public static final int
LAST_VIEW_SLIDE_VIEW
public static final int
LAST_VIEW_OUTLINE_VIEW
public static final int
LAST_VIEW_NOTES
private byte[]
_header
private static long
_type
private byte[]
reserved
private int
lastViewedSlideID
private int
pptVersion
private int
lastUserEditAtomOffset
private int
persistPointersOffset
private int
docPersistRef
private int
maxPersistWritten
private short
lastViewType
Constructors Summary
protected UserEditAtom(byte[] source, int start, int len)
For the UserEdit Atom

		// Sanity Checking
		if(len < 34) { len = 34; }

		// Get the header
		_header = new byte[8];
		System.arraycopy(source,start,_header,0,8);

		// Get the last viewed slide ID
		lastViewedSlideID = (int)LittleEndian.getInt(source,start+0+8);

		// Get the PPT version
		pptVersion = (int)LittleEndian.getInt(source,start+4+8);

		// 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 = (int)LittleEndian.getInt(source,start+8+8);

		// Get the offset to the persist pointers
		// This will be the byte offset on disk where the preceding 
		//  PersistPtrFullBlock or PersistPtrIncrementalBlock starts
		persistPointersOffset = (int)LittleEndian.getInt(source,start+12+8);

		// Get the persist reference for the document persist object
		// Normally seems to be 1
		docPersistRef = (int)LittleEndian.getInt(source,start+16+8);

		// Maximum number of persist objects written
		maxPersistWritten = (int)LittleEndian.getInt(source,start+20+8);
		
		// Last view type
		lastViewType = (short)LittleEndian.getShort(source,start+24+8);

		// There might be a few more bytes, which are a reserved field
		reserved = new byte[len-26-8];
		System.arraycopy(source,start+26+8,reserved,0,reserved.length);
	
Methods Summary
public intgetDocPersistRef()

 return docPersistRef; 
public intgetLastUserEditAtomOffset()

 return lastUserEditAtomOffset; 
public shortgetLastViewType()

 return lastViewType; 
public intgetLastViewedSlideID()


	// Somewhat user facing getters
	    return lastViewedSlideID; 
public intgetMaxPersistWritten()

 return maxPersistWritten; 
public intgetPersistPointersOffset()

 return persistPointersOffset; 
public longgetRecordType()
We are of type 4085

 return _type; 
public voidsetLastUserEditAtomOffset(int offset)

 lastUserEditAtomOffset = offset; 
public voidsetLastViewType(short type)

 lastViewType=type; 
public voidsetPersistPointersOffset(int offset)

 persistPointersOffset = offset; 
public voidupdateOtherRecordReferences(java.util.Hashtable oldToNewReferencesLookup)
At write-out time, update the references to PersistPtrs and other UserEditAtoms to point to their new positions

		// Look up the new positions of our preceding UserEditAtomOffset
		if(lastUserEditAtomOffset != 0) {
			Integer newLocation = (Integer)oldToNewReferencesLookup.get(new Integer(lastUserEditAtomOffset));
			if(newLocation == null) {
				throw new RuntimeException("Couldn't find the new location of the UserEditAtom that used to be at " + lastUserEditAtomOffset);
			}
			lastUserEditAtomOffset = newLocation.intValue();
		}

		// Ditto for our PersistPtr
		Integer newLocation = (Integer)oldToNewReferencesLookup.get(new Integer(persistPointersOffset));
		if(newLocation == null) {
			throw new RuntimeException("Couldn't find the new location of the PersistPtr that used to be at " + persistPointersOffset);
		}
		persistPointersOffset = newLocation.intValue();
	
public voidwriteOut(java.io.OutputStream out)
Write the contents of the record back, so it can be written to disk

		// 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);

		// Reserved fields
		out.write(reserved);