// Links to our more interesting children
private DocumentAtom documentAtom;
- private Record environment;
+ private Environment environment;
private SlideListWithText[] slwts;
/**
* 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
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
--- /dev/null
+
+/* ====================================================================
+ 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);
+ }
+}
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);
// 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();
}
}
}
}
- // 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
// 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<docChildren.length; i++) {
- // Look for SlideListWithText
- if(docChildren[i] instanceof SlideListWithText) {
- slwtV.add(docChildren[i]);
- }
- // Look for FontCollection under Environment
- if(docChildren[i].getRecordType() == RecordTypes.Environment.typeID) {
- Record[] envChildren = docChildren[i].getChildRecords();
- for(int j=0; j<envChildren.length; j++) {
- if(envChildren[j] instanceof FontCollection) {
- _fonts = (FontCollection)envChildren[j];
- }
- }
- }
+ SlideListWithText[] slwts = _documentRecord.getSlideListWithTexts();
+ for(int i=0; i<slwts.length; i++) {
+ slwtV.add(slwts[i]);
}
-
+
// For now, grab out all the sets of Atoms in the SlideListWithText's
// Only store those which aren't empty
// Also, get the list of IDs while we're at it