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 2006/03/19 17:09:53 UTC
svn commit: r386986 - in
/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf:
record/Document.java record/Environment.java record/RecordTypes.java
usermodel/SlideShow.java
Author: nick
Date: Sun Mar 19 08:09:51 2006
New Revision: 386986
URL: http://svn.apache.org/viewcvs?rev=386986&view=rev
Log:
Add an Environment record, and make the code simpler
Added:
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Environment.java
Modified:
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Document.java
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Document.java
URL: http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Document.java?rev=386986&r1=386985&r2=386986&view=diff
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Document.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Document.java Sun Mar 19 08:09:51 2006
@@ -35,7 +35,7 @@
// Links to our more interesting children
private DocumentAtom documentAtom;
- private Record environment;
+ private Environment environment;
private SlideListWithText[] slwts;
/**
@@ -46,7 +46,7 @@
* 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 @@
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
Added: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Environment.java
URL: http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Environment.java?rev=386986&view=auto
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Environment.java (added)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Environment.java Sun Mar 19 08:09:51 2006
@@ -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);
+ }
+}
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
URL: http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java?rev=386986&r1=386985&r2=386986&view=diff
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java Sun Mar 19 08:09:51 2006
@@ -41,7 +41,7 @@
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);
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
URL: http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java?rev=386986&r1=386985&r2=386986&view=diff
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java Sun Mar 19 08:09:51 2006
@@ -201,8 +201,10 @@
// 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 @@
}
- // 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 @@
// 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
---------------------------------------------------------------------
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/