You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by ni...@apache.org on 2005/06/09 17:13:20 UTC

cvs commit: jakarta-poi/src/scratchpad/src/org/apache/poi/hslf/dev SlideShowRecordDumper.java UserEditAndPersistListing.java

nick        2005/06/09 08:13:20

  Modified:    src/scratchpad/src/org/apache/poi/hslf/dev
                        SlideShowRecordDumper.java
                        UserEditAndPersistListing.java
  Log:
  Improved handling of byte level position sensitive records
  
  Revision  Changes    Path
  1.2       +1 -1      jakarta-poi/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowRecordDumper.java
  
  Index: SlideShowRecordDumper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowRecordDumper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SlideShowRecordDumper.java	28 May 2005 05:35:59 -0000	1.1
  +++ SlideShowRecordDumper.java	9 Jun 2005 15:13:20 -0000	1.2
  @@ -47,7 +47,7 @@
     public static void main(String args[]) throws IOException
     {
   	if(args.length == 0) {
  -		System.err.println("Useage: SlideShowDumper <filename>");
  +		System.err.println("Useage: SlideShowRecordDumper <filename>");
   		return;
   	}
   
  
  
  
  1.2       +43 -0     jakarta-poi/src/scratchpad/src/org/apache/poi/hslf/dev/UserEditAndPersistListing.java
  
  Index: UserEditAndPersistListing.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hslf/dev/UserEditAndPersistListing.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UserEditAndPersistListing.java	28 May 2005 05:35:59 -0000	1.1
  +++ UserEditAndPersistListing.java	9 Jun 2005 15:13:20 -0000	1.2
  @@ -22,7 +22,14 @@
   import org.apache.poi.hslf.*;
   import org.apache.poi.hslf.record.*;
   
  +import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  +import org.apache.poi.poifs.filesystem.POIFSDocument;
  +import org.apache.poi.poifs.filesystem.DocumentEntry;
  +import org.apache.poi.poifs.filesystem.DocumentInputStream;
  +import org.apache.poi.util.LittleEndian;
  +
   import java.io.*;
  +import java.util.Hashtable;
   
   /**
    * Uses record level code to locate UserEditAtom records, and other
  @@ -30,13 +37,18 @@
    *  illuminate quite what all the offsets mean
    */
   public class UserEditAndPersistListing {
  +	private static byte[] fileContents;
  +
   	public static void main(String[] args) throws Exception {
   		if(args.length < 1) {
   			System.err.println("Need to give a filename");
   			System.exit(1);
   		}
   
  +
  +		// Create the slideshow object, for normal working with
   		HSLFSlideShow ss = new HSLFSlideShow(args[0]);
  +		fileContents = ss.getUnderlyingBytes();
   		System.out.println("");
   
   		// Find any persist ones first
  @@ -52,6 +64,26 @@
   			if(r.getRecordType() == 6002l) {
   				// PersistPtrIncrementalBlock
   				System.out.println("Found PersistPtrIncrementalBlock at " + pos + " (" + Integer.toHexString(pos) + ")");
  +				PersistPtrHolder pph = (PersistPtrHolder)r;
  +
  +				// Check the sheet offsets
  +				int[] sheetIDs = pph.getKnownSlideIDs();
  +				Hashtable sheetOffsets = pph.getSlideLocationsLookup();
  +				for(int j=0; j<sheetIDs.length; j++) {
  +					Integer id = new Integer(sheetIDs[j]);
  +					Integer offset = (Integer)sheetOffsets.get(id);
  +
  +					System.out.println("  Knows about sheet " + id);
  +					System.out.println("    That sheet lives at " + offset);
  +
  +					Record atPos = findRecordAtPos(offset.intValue());
  +					System.out.println("    The record at that pos is of type " + atPos.getRecordType());
  +					System.out.println("    The record at that pos has class " + atPos.getClass().getName());
  +
  +					if(! (atPos instanceof PositionDependentRecord)) {
  +						System.out.println("    ** The record class isn't position aware! **");
  +					}
  +				}
   			}
   
   			// Increase the position by the on disk size
  @@ -92,4 +124,15 @@
   		
   		System.out.println("");
   	}
  +
  +
  +	// Finds the record at a given position
  +	public static Record findRecordAtPos(int pos) {
  +		long type = LittleEndian.getUShort(fileContents, pos+2);
  +		long rlen = LittleEndian.getUInt(fileContents, pos+4);
  +
  +		Record r = Record.createRecordForType(type,fileContents,pos,(int)rlen+8);
  +		
  +		return r;
  +	}
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/