001: /* ====================================================================
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016: ==================================================================== */
017:
018: package org.apache.poi.hslf.record;
019:
020: import java.util.HashMap;
021: import java.lang.reflect.Field;
022:
023: /**
024: * List of all known record types in a PowerPoint document, and the
025: * classes that handle them.
026: * There are two categories of records:
027: * <li> PowerPoint records: 0 <= info <= 10002 (will carry class info)
028: * <li> Escher records: info >= 0xF000 (handled by DDF, so no class info)
029: *
030: * @author Yegor Kozlov
031: * @author Nick Burch
032: */
033: public class RecordTypes {
034: public static HashMap typeToName;
035: public static HashMap typeToClass;
036:
037: public static final Type Unknown = new Type(0, null);
038: public static final Type Document = new Type(1000, Document.class);
039: public static final Type DocumentAtom = new Type(1001,
040: DocumentAtom.class);
041: public static final Type EndDocument = new Type(1002, null);
042: public static final Type Slide = new Type(1006, Slide.class);
043: public static final Type SlideAtom = new Type(1007, SlideAtom.class);
044: public static final Type Notes = new Type(1008, Notes.class);
045: public static final Type NotesAtom = new Type(1009, NotesAtom.class);
046: public static final Type Environment = new Type(1010,
047: Environment.class);
048: public static final Type SlidePersistAtom = new Type(1011,
049: SlidePersistAtom.class);
050: public static final Type SSlideLayoutAtom = new Type(1015, null);
051: public static final Type MainMaster = new Type(1016,
052: MainMaster.class);
053: public static final Type SSSlideInfoAtom = new Type(1017, null);
054: public static final Type SlideViewInfo = new Type(1018, null);
055: public static final Type GuideAtom = new Type(1019, null);
056: public static final Type ViewInfo = new Type(1020, null);
057: public static final Type ViewInfoAtom = new Type(1021, null);
058: public static final Type SlideViewInfoAtom = new Type(1022, null);
059: public static final Type VBAInfo = new Type(1023, null);
060: public static final Type VBAInfoAtom = new Type(1024, null);
061: public static final Type SSDocInfoAtom = new Type(1025, null);
062: public static final Type Summary = new Type(1026, null);
063: public static final Type DocRoutingSlip = new Type(1030, null);
064: public static final Type OutlineViewInfo = new Type(1031, null);
065: public static final Type SorterViewInfo = new Type(1032, null);
066: public static final Type ExObjList = new Type(1033, ExObjList.class);
067: public static final Type ExObjListAtom = new Type(1034,
068: ExObjListAtom.class);
069: public static final Type PPDrawingGroup = new Type(1035,
070: PPDrawingGroup.class);
071: public static final Type PPDrawing = new Type(1036, PPDrawing.class);
072: public static final Type NamedShows = new Type(1040, null);
073: public static final Type NamedShow = new Type(1041, null);
074: public static final Type NamedShowSlides = new Type(1042, null);
075: public static final Type SheetProperties = new Type(1044, null);
076: public static final Type List = new Type(2000, null);
077: public static final Type FontCollection = new Type(2005,
078: FontCollection.class);
079: public static final Type BookmarkCollection = new Type(2019, null);
080: public static final Type SoundCollAtom = new Type(2021, null);
081: public static final Type Sound = new Type(2022, null);
082: public static final Type SoundData = new Type(2023, null);
083: public static final Type BookmarkSeedAtom = new Type(2025, null);
084: public static final Type ColorSchemeAtom = new Type(2032,
085: ColorSchemeAtom.class);
086: public static final Type ExObjRefAtom = new Type(3009, null);
087: public static final Type OEShapeAtom = new Type(3009, null);
088: public static final Type OEPlaceholderAtom = new Type(3011,
089: OEPlaceholderAtom.class);
090: public static final Type GPopublicintAtom = new Type(3024, null);
091: public static final Type GRatioAtom = new Type(3031, null);
092: public static final Type OutlineTextRefAtom = new Type(3998,
093: OutlineTextRefAtom.class);
094: public static final Type TextHeaderAtom = new Type(3999,
095: TextHeaderAtom.class);
096: public static final Type TextCharsAtom = new Type(4000,
097: TextCharsAtom.class);
098: public static final Type StyleTextPropAtom = new Type(4001,
099: StyleTextPropAtom.class);
100: public static final Type BaseTextPropAtom = new Type(4002, null);
101: public static final Type TxMasterStyleAtom = new Type(4003,
102: TxMasterStyleAtom.class);
103: public static final Type TxCFStyleAtom = new Type(4004, null);
104: public static final Type TxPFStyleAtom = new Type(4005, null);
105: public static final Type TextRulerAtom = new Type(4006, null);
106: public static final Type TextBookmarkAtom = new Type(4007, null);
107: public static final Type TextBytesAtom = new Type(4008,
108: TextBytesAtom.class);
109: public static final Type TxSIStyleAtom = new Type(4009, null);
110: public static final Type TextSpecInfoAtom = new Type(4010, null);
111: public static final Type DefaultRulerAtom = new Type(4011, null);
112: public static final Type FontEntityAtom = new Type(4023,
113: FontEntityAtom.class);
114: public static final Type FontEmbeddedData = new Type(4024, null);
115: public static final Type CString = new Type(4026, CString.class);
116: public static final Type MetaFile = new Type(4033, null);
117: public static final Type ExOleObjAtom = new Type(4035,
118: ExOleObjAtom.class);
119: public static final Type SrKinsoku = new Type(4040, null);
120: public static final Type HandOut = new Type(4041, null);
121: public static final Type ExEmbed = new Type(4044, ExEmbed.class);
122: public static final Type ExEmbedAtom = new Type(4045,
123: ExEmbedAtom.class);
124: public static final Type ExLink = new Type(4046, null);
125: public static final Type BookmarkEntityAtom = new Type(4048, null);
126: public static final Type ExLinkAtom = new Type(4049, null);
127: public static final Type SrKinsokuAtom = new Type(4050, null);
128: public static final Type ExHyperlinkAtom = new Type(4051,
129: ExHyperlinkAtom.class);
130: public static final Type ExHyperlink = new Type(4055,
131: ExHyperlink.class);
132: public static final Type SlideNumberMCAtom = new Type(4056, null);
133: public static final Type HeadersFooters = new Type(4057, null);
134: public static final Type HeadersFootersAtom = new Type(4058, null);
135: public static final Type TxInteractiveInfoAtom = new Type(4063,
136: TxInteractiveInfoAtom.class);
137: public static final Type CharFormatAtom = new Type(4066, null);
138: public static final Type ParaFormatAtom = new Type(4067, null);
139: public static final Type RecolorInfoAtom = new Type(4071, null);
140: public static final Type ExQuickTimeMovie = new Type(4074, null);
141: public static final Type ExQuickTimeMovieData = new Type(4075, null);
142: public static final Type ExControl = new Type(4078, null);
143: public static final Type SlideListWithText = new Type(4080,
144: SlideListWithText.class);
145: public static final Type InteractiveInfo = new Type(4082,
146: InteractiveInfo.class);
147: public static final Type InteractiveInfoAtom = new Type(4083,
148: InteractiveInfoAtom.class);
149: public static final Type UserEditAtom = new Type(4085,
150: UserEditAtom.class);
151: public static final Type CurrentUserAtom = new Type(4086, null);
152: public static final Type DateTimeMCAtom = new Type(4087, null);
153: public static final Type GenericDateMCAtom = new Type(4088, null);
154: public static final Type FooterMCAtom = new Type(4090, null);
155: public static final Type ExControlAtom = new Type(4091, null);
156: public static final Type ExMediaAtom = new Type(4100, null);
157: public static final Type ExVideo = new Type(4101, null);
158: public static final Type ExAviMovie = new Type(4102, null);
159: public static final Type ExMCIMovie = new Type(4103, null);
160: public static final Type ExMIDIAudio = new Type(4109, null);
161: public static final Type ExCDAudio = new Type(4110, null);
162: public static final Type ExWAVAudioEmbedded = new Type(4111, null);
163: public static final Type ExWAVAudioLink = new Type(4112, null);
164: public static final Type ExOleObjStg = new Type(4113,
165: ExOleObjStg.class);
166: public static final Type ExCDAudioAtom = new Type(4114, null);
167: public static final Type ExWAVAudioEmbeddedAtom = new Type(4115,
168: null);
169: public static final Type AnimationInfoAtom = new Type(4116, null);
170: public static final Type RTFDateTimeMCAtom = new Type(4117, null);
171: public static final Type ProgTags = new Type(5000,
172: DummyPositionSensitiveRecordWithChildren.class);
173: public static final Type ProgStringTag = new Type(5001, null);
174: public static final Type ProgBinaryTag = new Type(5002,
175: DummyPositionSensitiveRecordWithChildren.class);
176: public static final Type BinaryTagData = new Type(5003,
177: DummyPositionSensitiveRecordWithChildren.class);
178: public static final Type PrpublicintOptions = new Type(6000, null);
179: public static final Type PersistPtrFullBlock = new Type(6001,
180: PersistPtrHolder.class);
181: public static final Type PersistPtrIncrementalBlock = new Type(
182: 6002, PersistPtrHolder.class);
183: public static final Type GScalingAtom = new Type(10001, null);
184: public static final Type GRColorAtom = new Type(10002, null);
185:
186: // Records ~12000 seem to be related to the Comments used in PPT 2000/XP
187: // (Comments in PPT97 are normal Escher text boxes)
188: public static final Type Comment2000 = new Type(12000,
189: Comment2000.class);
190: public static final Type Comment2000Atom = new Type(12001,
191: Comment2000Atom.class);
192: public static final Type Comment2000Summary = new Type(12004, null);
193: public static final Type Comment2000SummaryAtom = new Type(12005,
194: null);
195:
196: // Records ~12050 seem to be related to Document Encryption
197: public static final Type DocumentEncryptionAtom = new Type(12052,
198: DocumentEncryptionAtom.class);
199:
200: //records greater then 0xF000 belong to with Microsoft Office Drawing format also known as Escher
201: public static final int EscherDggContainer = 0xf000;
202: public static final int EscherDgg = 0xf006;
203: public static final int EscherCLSID = 0xf016;
204: public static final int EscherOPT = 0xf00b;
205: public static final int EscherBStoreContainer = 0xf001;
206: public static final int EscherBSE = 0xf007;
207: public static final int EscherBlip_START = 0xf018;
208: public static final int EscherBlip_END = 0xf117;
209: public static final int EscherDgContainer = 0xf002;
210: public static final int EscherDg = 0xf008;
211: public static final int EscherRegroupItems = 0xf118;
212: public static final int EscherColorScheme = 0xf120;
213: public static final int EscherSpgrContainer = 0xf003;
214: public static final int EscherSpContainer = 0xf004;
215: public static final int EscherSpgr = 0xf009;
216: public static final int EscherSp = 0xf00a;
217: public static final int EscherTextbox = 0xf00c;
218: public static final int EscherClientTextbox = 0xf00d;
219: public static final int EscherAnchor = 0xf00e;
220: public static final int EscherChildAnchor = 0xf00f;
221: public static final int EscherClientAnchor = 0xf010;
222: public static final int EscherClientData = 0xf011;
223: public static final int EscherSolverContainer = 0xf005;
224: public static final int EscherConnectorRule = 0xf012;
225: public static final int EscherAlignRule = 0xf013;
226: public static final int EscherArcRule = 0xf014;
227: public static final int EscherClientRule = 0xf015;
228: public static final int EscherCalloutRule = 0xf017;
229: public static final int EscherSelection = 0xf119;
230: public static final int EscherColorMRU = 0xf11a;
231: public static final int EscherDeletedPspl = 0xf11d;
232: public static final int EscherSplitMenuColors = 0xf11e;
233: public static final int EscherOleObject = 0xf11f;
234: public static final int EscherUserDefined = 0xf122;
235:
236: /**
237: * Returns name of the record by its type
238: *
239: * @param type section of the record header
240: * @return name of the record
241: */
242: public static String recordName(int type) {
243: String name = (String) typeToName.get(new Integer(type));
244: if (name == null)
245: name = "Unknown" + type;
246: return name;
247: }
248:
249: /**
250: * Returns the class handling a record by its type.
251: * If given an un-handled PowerPoint record, will return a dummy
252: * placeholder class. If given an unknown PowerPoint record, or
253: * and Escher record, will return null.
254: *
255: * @param type section of the record header
256: * @return class to handle the record, or null if an unknown (eg Escher) record
257: */
258: public static Class recordHandlingClass(int type) {
259: Class c = (Class) typeToClass.get(new Integer(type));
260: return c;
261: }
262:
263: static {
264: typeToName = new HashMap();
265: typeToClass = new HashMap();
266: try {
267: Field[] f = RecordTypes.class.getFields();
268: for (int i = 0; i < f.length; i++) {
269: Object val = f[i].get(null);
270:
271: // Escher record, only store ID -> Name
272: if (val instanceof Integer) {
273: typeToName.put(val, f[i].getName());
274: }
275: // PowerPoint record, store ID -> Name and ID -> Class
276: if (val instanceof Type) {
277: Type t = (Type) val;
278: Class c = t.handlingClass;
279: Integer id = new Integer(t.typeID);
280: if (c == null) {
281: c = UnknownRecordPlaceholder.class;
282: }
283:
284: typeToName.put(id, f[i].getName());
285: typeToClass.put(id, c);
286: }
287: }
288: } catch (IllegalAccessException e) {
289: throw new RuntimeException(
290: "Failed to initialize records types");
291: }
292: }
293:
294: /**
295: * Wrapper for the details of a PowerPoint or Escher record type.
296: * Contains both the type, and the handling class (if any), and
297: * offers methods to get either back out.
298: */
299: public static class Type {
300: public int typeID;
301: public Class handlingClass;
302:
303: public Type(int typeID, Class handlingClass) {
304: this.typeID = typeID;
305: this.handlingClass = handlingClass;
306: }
307: }
308: }
|