FileDocCategorySizeDatePackage
Document.javaAPI DocApache Poi 3.0.16113Thu May 31 18:45:28 BST 2007org.apache.poi.hslf.record

Document

public class Document extends PositionDependentRecordContainer
Master container for Document. There is one of these for every slideshow, and it holds lots of definitions, and some summaries.
author
Nick Burch

Fields Summary
private byte[]
_header
private static long
_type
private DocumentAtom
documentAtom
private Environment
environment
private PPDrawingGroup
ppDrawing
private SlideListWithText[]
slwts
private ExObjList
exObjList
Constructors Summary
protected Document(byte[] source, int start, int len)
Set things up, and find our more interesting children

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

		// Find our children
		_children = Record.findChildRecords(source,start+8,len-8);

		// Our first one should be a document atom
		if(! (_children[0] instanceof DocumentAtom)) {
			throw new IllegalStateException("The first child of a Document must be a DocumentAtom");
		}
		documentAtom = (DocumentAtom)_children[0];

		// Find how many SlideListWithTexts we have
		// Also, grab the Environment and PPDrawing records
		//  on our way past
		int slwtcount = 0;
		for(int i=1; i<_children.length; i++) {
			if(_children[i] instanceof SlideListWithText) {
				slwtcount++;
			}
			if(_children[i] instanceof Environment) {
				environment = (Environment)_children[i];
			}
			if(_children[i] instanceof PPDrawingGroup) {
				ppDrawing = (PPDrawingGroup)_children[i];
			}
			if(_children[i] instanceof ExObjList) {
				exObjList = (ExObjList)_children[i];
			}
		}
		
		// You should only every have 1, 2 or 3 SLWTs
		//  (normally it's 2, or 3 if you have notes)
		// Complain if it's not
		if(slwtcount == 0) {
			logger.log(POILogger.WARN, "No SlideListWithText's found - there should normally be at least one!");
		}
		if(slwtcount > 3) {
			logger.log(POILogger.WARN, "Found " + slwtcount + " SlideListWithTexts - normally there should only be three!");
		}
		
		// Now grab all the SLWTs
		slwts = new SlideListWithText[slwtcount];
		slwtcount = 0;
		for(int i=1; i<_children.length; i++) {
			if(_children[i] instanceof SlideListWithText) {
				slwts[slwtcount] = (SlideListWithText)_children[i];
				slwtcount++;
			}
		}
	
Methods Summary
public voidaddSlideListWithText(org.apache.poi.hslf.record.SlideListWithText slwt)
Adds a new SlideListWithText record, at the appropriate point in the child records.

		// The new SlideListWithText should go in 
		//  just before the EndDocumentRecord
		Record endDoc = _children[_children.length - 1];
		if(endDoc.getRecordType() != RecordTypes.EndDocument.typeID) {
			throw new IllegalStateException("The last child record of a Document should be EndDocument, but it was " + endDoc);
		}
		
		// Add in the record
		addChildBefore(slwt, endDoc);
			
		// Updated our cached list of SlideListWithText records
		int newSize = slwts.length + 1;
		SlideListWithText[] nl = new SlideListWithText[newSize];
		System.arraycopy(slwts, 0, nl, 0, slwts.length);
		nl[nl.length-1] = slwt;
		slwts = nl;
	
public org.apache.poi.hslf.record.DocumentAtomgetDocumentAtom()
Returns the DocumentAtom of this Document

 // Can be null

	      	 
	    return documentAtom; 
public org.apache.poi.hslf.record.EnvironmentgetEnvironment()
Returns the Environment of this Notes, which lots of settings for the document in it

 return environment; 
public org.apache.poi.hslf.record.ExObjListgetExObjList()
Returns the ExObjList, which holds the references to external objects used in the slides. This may be null, if there are no external references.

 return exObjList; 
public org.apache.poi.hslf.record.SlideListWithTextgetMasterSlideListWithText()
Returns the SlideListWithText that deals with the Master Slides

 
		if(slwts.length > 0) { return slwts[0]; }
		return null; 
public org.apache.poi.hslf.record.SlideListWithTextgetNotesSlideListWithText()
Returns the SlideListWithText that deals with the notes, or null if there isn't one

		if(slwts.length > 2) { return slwts[2]; }
		return null; 
public org.apache.poi.hslf.record.PPDrawingGroupgetPPDrawingGroup()
Returns the PPDrawingGroup, which holds an Escher Structure that contains information on pictures in the slides.

 return ppDrawing; 
public longgetRecordType()
We are of type 1000

 return _type; 
public org.apache.poi.hslf.record.SlideListWithText[]getSlideListWithTexts()
Returns all the SlideListWithTexts that are defined for this Document. They hold the text, and some of the text properties, which are referred to by the slides. This will normally return an array of size 2 or 3

 return slwts; 
public org.apache.poi.hslf.record.SlideListWithTextgetSlideSlideListWithText()
Returns the SlideListWithText that deals with the Slides, or null if there isn't one

 
		if(slwts.length > 1) { return slwts[1]; }
		return null; 
public voidwriteOut(java.io.OutputStream out)
Write the contents of the record back, so it can be written to disk

		writeOut(_header[0],_header[1],_type,_children,out);