diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/Document.java b/src/scratchpad/src/org/apache/poi/hslf/record/Document.java index 153411628..c3c0012dd 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/Document.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/Document.java @@ -35,7 +35,7 @@ public class Document extends PositionDependentRecordContainer // Links to our more interesting children private DocumentAtom documentAtom; - private Record environment; + private Environment environment; private SlideListWithText[] slwts; /** @@ -46,7 +46,7 @@ public class Document extends PositionDependentRecordContainer * Returns the Environment of this Notes, which lots of * settings for the document in it */ - public Record getEnvironment() { return environment; } + public Environment getEnvironment() { return environment; } /** * Returns all the SlideListWithTexts that are defined for * this Document. They hold the text, and some of the text @@ -79,8 +79,8 @@ public class Document extends PositionDependentRecordContainer if(_children[i] instanceof SlideListWithText) { slwtcount++; } - if(_children[i].getRecordType() == RecordTypes.Environment.typeID) { - environment = _children[i]; + if(_children[i] instanceof Environment) { + environment = (Environment)_children[i]; } } // Now grab them all diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/Environment.java b/src/scratchpad/src/org/apache/poi/hslf/record/Environment.java new file mode 100644 index 000000000..831e9857f --- /dev/null +++ b/src/scratchpad/src/org/apache/poi/hslf/record/Environment.java @@ -0,0 +1,80 @@ + +/* ==================================================================== + Copyright 2002-2004 Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + + +package org.apache.poi.hslf.record; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * Environment, which contains lots of settings for the document. + * + * @author Nick Burch + */ + +public class Environment extends PositionDependentRecordContainer +{ + private byte[] _header; + private static long _type = 1010; + + // Links to our more interesting children + private FontCollection fontCollection; + + /** + * Returns the FontCollection of this Environment + */ + public FontCollection getFontCollection() { return fontCollection; } + + + /** + * Set things up, and find our more interesting children + */ + protected Environment(byte[] source, int start, int len) { + // 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); + + // Find our FontCollection record + for(int i=0; i<_children.length; i++) { + if(_children[i] instanceof FontCollection) { + fontCollection = (FontCollection)_children[i]; + } + } + + if(fontCollection == null) { + throw new IllegalStateException("Environment didn't contain a FontCollection record!"); + } + } + + + /** + * We are of type 1010 + */ + 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); + } +} diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java b/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java index d31bf84da..eaca249e9 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java @@ -41,7 +41,7 @@ public class RecordTypes { public static final Type SlideAtom = new Type(1007,SlideAtom.class); public static final Type Notes = new Type(1008,Notes.class); public static final Type NotesAtom = new Type(1009,NotesAtom.class); - public static final Type Environment = new Type(1010,DummyRecordWithChildren.class); + public static final Type Environment = new Type(1010,Environment.class); public static final Type SlidePersistAtom = new Type(1011,SlidePersistAtom.class); public static final Type SSlideLayoutAtom = new Type(1015,null); public static final Type MainMaster = new Type(1016,DummyPositionSensitiveRecordWithChildren.class); diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java index 1fc4c6fda..ac16539c4 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java @@ -201,8 +201,10 @@ public class SlideShow // Now look for the interesting records in there for(int i=0; i<_mostRecentCoreRecords.length; i++) { + // Find the Document, and interesting things in it if(_mostRecentCoreRecords[i].getRecordType() == RecordTypes.Document.typeID) { _documentRecord = (Document)_mostRecentCoreRecords[i]; + _fonts = _documentRecord.getEnvironment().getFontCollection(); } } } @@ -238,7 +240,7 @@ public class SlideShow } - // Now look for SlideListWithTexts in the most up-to-date Document Record + // Fetch the SlideListWithTexts in the most up-to-date Document Record // // Need to get the SlideAtomsSets for all of these. Then, query the // SlidePersistAtom, and group stuff together between SLWT blocks @@ -257,23 +259,11 @@ public class SlideShow // There shouldn't be any text duplication - only using the most // record Document record's SLWTs should see to that - Record[] docChildren = _documentRecord.getChildRecords(); - for(int i=0; i