Removed image size hack from TileBlog.cs
[beagle.git] / Filters / FilterPPT.cs
blobb9279427db69fd4daaa07562d6121fa049eaf326
1 /* -*- Mode: csharp; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 //
3 // FilterExcel.cs
4 //
5 // Copyright (C) 2004 Novell, Inc.
6 //
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a
10 // copy of this software and associated documentation files (the "Software"),
11 // to deal in the Software without restriction, including without limitation
12 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 // and/or sell copies of the Software, and to permit persons to whom the
14 // Software is furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 // DEALINGS IN THE SOFTWARE.
29 using System;
30 using System.Collections;
31 using System.IO;
32 using System.Text;
33 using Gsf;
35 internal class RecordType
38 public enum TypeCode {
39 Unknown = 0,
40 Document = 1000,
41 DocumentAtom = 1001,
42 EndDocument = 1002,
43 Slide = 1006,
44 SlideAtom = 1007,
45 Notes = 1008,
46 NotesAtom = 1009,
47 Environment = 1010,
48 SlidePersistAtom = 1011,
49 SSlideLayoutAtom = 1015,
50 MainMaster = 1016,
51 SSSlideInfoAtom = 1017,
52 SlideViewInfo = 1018,
53 GuideAtom = 1019,
54 ViewInfo = 1020,
55 ViewInfoAtom = 1021,
56 SlideViewInfoAtom = 1022,
57 VBAInfo = 1023,
58 VBAInfoAtom = 1024,
59 SSDocInfoAtom = 1025,
60 Summary = 1026,
61 DocRoutingSlip = 1030,
62 OutlineViewInfo = 1031,
63 SorterViewInfo = 1032,
64 ExObjList = 1033,
65 ExObjListAtom = 1034,
66 PPDrawingGroup = 1035, //FIXME: Office Art File Format Docu
67 PPDrawing = 1036, //FIXME: Office Art File Format Docu
68 NamedShows = 1040, // don't know if container
69 NamedShow = 1041,
70 NamedShowSlides = 1042, // don't know if container
71 List = 2000,
72 FontCollection = 2005,
73 BookmarkCollection = 2019,
74 SoundCollAtom = 2021,
75 Sound = 2022,
76 SoundData = 2023,
77 BookmarkSeedAtom = 2025,
78 ColorSchemeAtom = 2032,
79 ExObjRefAtom = 3009,
80 OEShapeAtom = 3009,
81 OEPlaceholderAtom = 3011,
82 GPointAtom = 3024,
83 GRatioAtom = 3031,
84 OutlineTextRefAtom = 3998,
85 TextHeaderAtom = 3999,
86 TextCharsAtom = 4000,
87 StyleTextPropAtom = 4001,
88 BaseTextPropAtom = 4002,
89 TxMasterStyleAtom = 4003,
90 TxCFStyleAtom = 4004,
91 TxPFStyleAtom = 4005,
92 TextRulerAtom = 4006,
93 TextBookmarkAtom = 4007,
94 TextBytesAtom = 4008,
95 TxSIStyleAtom = 4009,
96 TextSpecInfoAtom = 4010,
97 DefaultRulerAtom = 4011,
98 FontEntityAtom = 4023,
99 FontEmbeddedData = 4024,
100 CString = 4026,
101 MetaFile = 4033,
102 ExOleObjAtom = 4035,
103 SrKinsoku = 4040,
104 HandOut = 4041,
105 ExEmbed = 4044,
106 ExEmbedAtom = 4045,
107 ExLink = 4046,
108 BookmarkEntityAtom = 4048,
109 ExLinkAtom = 4049,
110 SrKinsokuAtom = 4050,
111 ExHyperlinkAtom = 4051,
112 ExHyperlink = 4055,
113 SlideNumberMCAtom = 4056,
114 HeadersFooters = 4057,
115 HeadersFootersAtom = 4058,
116 TxInteractiveInfoAtom = 4063,
117 CharFormatAtom = 4066,
118 ParaFormatAtom = 4067,
119 RecolorInfoAtom = 4071,
120 ExQuickTimeMovie = 4074,
121 ExQuickTimeMovieData = 4075,
122 ExControl = 4078,
123 SlideListWithText = 4080,
124 InteractiveInfo = 4082,
125 InteractiveInfoAtom = 4083,
126 UserEditAtom = 4085,
127 CurrentUserAtom = 4086,
128 DateTimeMCAtom = 4087,
129 GenericDateMCAtom = 4088,
130 FooterMCAtom = 4090,
131 ExControlAtom = 4091,
132 ExMediaAtom = 4100,
133 ExVideo = 4101,
134 ExAviMovie = 4102,
135 ExMCIMovie = 4103,
136 ExMIDIAudio = 4109,
137 ExCDAudio = 4110,
138 ExWAVAudioEmbedded = 4111,
139 ExWAVAudioLink = 4112,
140 ExOleObjStg = 4113,
141 ExCDAudioAtom = 4114,
142 ExWAVAudioEmbeddedAtom = 4115,
143 AnimationInfoAtom = 4116,
144 RTFDateTimeMCAtom = 4117,
145 ProgTags = 5000, // don't know if container
146 ProgStringTag = 5001,
147 ProgBinaryTag = 5002,
148 BinaryTagData = 5003,
149 PrintOptions = 6000,
150 PersistPtrFullBlock = 6001, // don't know if container
151 PersistPtrIncrementalBlock = 6002, // don't know if container
152 GScalingAtom = 10001,
153 GRColorAtom = 10002,
154 EscherDggContainer = 0xf000, /* Drawing Group Container */
155 EscherDgg = 0xf006,
156 EscherCLSID = 0xf016,
157 EscherOPT = 0xf00b,
158 EscherBStoreContainer = 0xf001,
159 EscherBSE = 0xf007,
160 EscherBlip_START = 0xf018, /* Blip types are between */
161 EscherBlip_END = 0xf117, /* these two values */
162 EscherDgContainer = 0xf002, /* Drawing Container */
163 EscherDg = 0xf008,
164 EscherRegroupItems = 0xf118,
165 EscherColorScheme = 0xf120, /* bug in docs */
166 EscherSpgrContainer = 0xf003,
167 EscherSpContainer = 0xf004,
168 EscherSpgr = 0xf009,
169 EscherSp = 0xf00a,
170 EscherTextbox = 0xf00c,
171 EscherClientTextbox = 0xf00d,
172 EscherAnchor = 0xf00e,
173 EscherChildAnchor = 0xf00f,
174 EscherClientAnchor = 0xf010,
175 EscherClientData = 0xf011,
176 EscherSolverContainer = 0xf005,
177 EscherConnectorRule = 0xf012, /* bug in docs */
178 EscherAlignRule = 0xf013,
179 EscherArcRule = 0xf014,
180 EscherClientRule = 0xf015,
181 EscherCalloutRule = 0xf017,
182 EscherSelection = 0xf119,
183 EscherColorMRU = 0xf11a,
184 EscherDeletedPspl = 0xf11d, /* bug in docs */
185 EscherSplitMenuColors = 0xf11e,
186 EscherOleObject = 0xf11f,
187 EscherUserDefined = 0xf122,
190 public TypeCode typecode;
191 public string name;
192 public bool is_container;
193 public bool do_read;
194 public int min_record_size;
195 public int max_record_size;
196 RecordType (TypeCode typecode, string name, bool is_container, bool do_read, int min_record_size, int max_record_size)
198 this.typecode = typecode;
199 this.name = name;
200 this.is_container = is_container;
201 this.do_read = do_read;
202 this.min_record_size = min_record_size;
203 this.max_record_size = max_record_size;
206 static RecordType[] types =
208 new RecordType ( TypeCode.Unknown, "Unknown", false, true, -1, -1 ),
209 new RecordType ( TypeCode.Document, "Document", true, true, -1, -1 ),
210 new RecordType ( TypeCode.DocumentAtom, "DocumentAtom", false, true, -1, -1 ),
211 new RecordType ( TypeCode.EndDocument, "EndDocument", false, true, -1, -1 ),
212 new RecordType ( TypeCode.Slide, "Slide", true, true, -1, -1 ),
213 new RecordType ( TypeCode.SlideAtom, "SlideAtom", false, true, -1, -1 ),
214 new RecordType ( TypeCode.Notes, "Notes", true, true, -1, -1 ),
215 new RecordType ( TypeCode.NotesAtom, "NotesAtom", false, true, -1, -1 ),
216 new RecordType ( TypeCode.Environment, "Environment", true, true, -1, -1 ),
217 new RecordType ( TypeCode.SlidePersistAtom, "SlidePersistAtom", false, true, -1, -1 ),
218 new RecordType ( TypeCode.SSlideLayoutAtom, "SSlideLayoutAtom", false, true, -1, -1 ),
219 new RecordType ( TypeCode.MainMaster, "MainMaster", true, true, -1, -1 ),
220 new RecordType ( TypeCode.SSSlideInfoAtom, "SSSlideInfoAtom", false, true, -1, -1 ),
221 new RecordType ( TypeCode.SlideViewInfo, "SlideViewInfo", true, true, -1, -1 ),
222 new RecordType ( TypeCode.GuideAtom, "GuideAtom", false, true, -1, -1 ),
223 new RecordType ( TypeCode.ViewInfo, "ViewInfo", true, true, -1, -1 ),
224 new RecordType ( TypeCode.ViewInfoAtom, "ViewInfoAtom", false, true, -1, -1 ),
225 new RecordType ( TypeCode.SlideViewInfoAtom, "SlideViewInfoAtom", false, true, -1, -1 ),
226 new RecordType ( TypeCode.VBAInfo, "VBAInfo", true, true, -1, -1 ),
227 new RecordType ( TypeCode.VBAInfoAtom, "VBAInfoAtom", false, true, -1, -1 ),
228 new RecordType ( TypeCode.SSDocInfoAtom, "SSDocInfoAtom", false, true, -1, -1 ),
229 new RecordType ( TypeCode.Summary, "Summary", true, true, -1, -1 ),
230 new RecordType ( TypeCode.DocRoutingSlip, "DocRoutingSlip", false, true, -1, -1 ),
231 new RecordType ( TypeCode.OutlineViewInfo, "OutlineViewInfo", true, true, -1, -1 ),
232 new RecordType ( TypeCode.SorterViewInfo, "SorterViewInfo", true, true, -1, -1 ),
233 new RecordType ( TypeCode.ExObjList, "ExObjList", true, true, -1, -1 ),
234 new RecordType ( TypeCode.ExObjListAtom, "ExObjListAtom", false, true, -1, -1 ),
235 new RecordType ( TypeCode.PPDrawingGroup, "PPDrawingGroup", true, true, -1, -1 ), //FIXME: Office Art File Format Docu
236 new RecordType ( TypeCode.PPDrawing, "PPDrawing", true, true, -1, -1 ), //FIXME: Office Art File Format Docu
237 new RecordType ( TypeCode.NamedShows, "NamedShows", false, true, -1, -1 ), // don't know if container
238 new RecordType ( TypeCode.NamedShow, "NamedShow", true, true, -1, -1 ),
239 new RecordType ( TypeCode.NamedShowSlides, "NamedShowSlides", false, true, -1, -1 ), // don't know if container
240 new RecordType ( TypeCode.List, "List", true, true, -1, -1 ),
241 new RecordType ( TypeCode.FontCollection, "FontCollection", true, true, -1, -1 ),
242 new RecordType ( TypeCode.BookmarkCollection, "BookmarkCollection", true, true, -1, -1 ),
243 new RecordType ( TypeCode.SoundCollAtom, "SoundCollAtom", false, true, -1, -1 ),
244 new RecordType ( TypeCode.Sound, "Sound", true, true, -1, -1 ),
245 new RecordType ( TypeCode.SoundData, "SoundData", false, true, -1, -1 ),
246 new RecordType ( TypeCode.BookmarkSeedAtom, "BookmarkSeedAtom", false, true, -1, -1 ),
247 new RecordType ( TypeCode.ColorSchemeAtom, "ColorSchemeAtom", false, true, -1, -1 ),
248 new RecordType ( TypeCode.ExObjRefAtom, "ExObjRefAtom", false, true, -1, -1 ),
249 new RecordType ( TypeCode.OEShapeAtom, "OEShapeAtom", false, true, -1, -1 ),
250 new RecordType ( TypeCode.OEPlaceholderAtom, "OEPlaceholderAtom", false, true, -1, -1 ),
251 new RecordType ( TypeCode.GPointAtom, "GPointAtom", false, true, -1, -1 ),
252 new RecordType ( TypeCode.GRatioAtom, "GRatioAtom", false, true, -1, -1 ),
253 new RecordType ( TypeCode.OutlineTextRefAtom, "OutlineTextRefAtom", false, true, -1, -1 ),
254 new RecordType ( TypeCode.TextHeaderAtom, "TextHeaderAtom", false, true, -1, -1 ),
255 new RecordType ( TypeCode.TextCharsAtom, "TextCharsAtom", false, true, -1, -1 ),
256 new RecordType ( TypeCode.StyleTextPropAtom, "StyleTextPropAtom", false, true, -1, -1 ),
257 new RecordType ( TypeCode.BaseTextPropAtom, "BaseTextPropAtom", false, true, -1, -1 ),
258 new RecordType ( TypeCode.TxMasterStyleAtom, "TxMasterStyleAtom", false, true, -1, -1 ),
259 new RecordType ( TypeCode.TxCFStyleAtom, "TxCFStyleAtom", false, true, -1, -1 ),
260 new RecordType ( TypeCode.TxPFStyleAtom, "TxPFStyleAtom", false, true, -1, -1 ),
261 new RecordType ( TypeCode.TextRulerAtom, "TextRulerAtom", false, true, -1, -1 ),
262 new RecordType ( TypeCode.TextBookmarkAtom, "TextBookmarkAtom", false, true, -1, -1 ),
263 new RecordType ( TypeCode.TextBytesAtom, "TextBytesAtom", false, true, -1, -1 ),
264 new RecordType ( TypeCode.TxSIStyleAtom, "TxSIStyleAtom", false, true, -1, -1 ),
265 new RecordType ( TypeCode.TextSpecInfoAtom, "TextSpecInfoAtom", false, true, -1, -1 ),
266 new RecordType ( TypeCode.DefaultRulerAtom, "DefaultRulerAtom", false, true, -1, -1 ),
267 new RecordType ( TypeCode.FontEntityAtom, "FontEntityAtom", false, true, -1, -1 ),
268 new RecordType ( TypeCode.FontEmbeddedData, "FontEmbeddedData", false, true, -1, -1 ),
269 new RecordType ( TypeCode.CString, "CString", false, true, -1, -1 ),
270 new RecordType ( TypeCode.MetaFile, "MetaFile", false, true, -1, -1 ),
271 new RecordType ( TypeCode.ExOleObjAtom, "ExOleObjAtom", false, true, -1, -1 ),
272 new RecordType ( TypeCode.SrKinsoku, "SrKinsoku", true, true, -1, -1 ),
273 new RecordType ( TypeCode.HandOut, "HandOut", true, true, -1, -1 ),
274 new RecordType ( TypeCode.ExEmbed, "ExEmbed", true, true, -1, -1 ),
275 new RecordType ( TypeCode.ExEmbedAtom, "ExEmbedAtom", false, true, -1, -1 ),
276 new RecordType ( TypeCode.ExLink, "ExLink", true, true, -1, -1 ),
277 new RecordType ( TypeCode.BookmarkEntityAtom, "BookmarkEntityAtom", false, true, -1, -1 ),
278 new RecordType ( TypeCode.ExLinkAtom, "ExLinkAtom", false, true, -1, -1 ),
279 new RecordType ( TypeCode.SrKinsokuAtom, "SrKinsokuAtom", false, true, -1, -1 ),
280 new RecordType ( TypeCode.ExHyperlinkAtom, "ExHyperlinkAtom", false, true, -1, -1 ),
281 new RecordType ( TypeCode.ExHyperlink, "ExHyperlink", true, true, -1, -1 ),
282 new RecordType ( TypeCode.SlideNumberMCAtom, "SlideNumberMCAtom", false, true, -1, -1 ),
283 new RecordType ( TypeCode.HeadersFooters, "HeadersFooters", true, true, -1, -1 ),
284 new RecordType ( TypeCode.HeadersFootersAtom, "HeadersFootersAtom", false, true, -1, -1 ),
285 new RecordType ( TypeCode.TxInteractiveInfoAtom, "TxInteractiveInfoAtom", false, true, -1, -1 ),
286 new RecordType ( TypeCode.CharFormatAtom, "CharFormatAtom", false, true, -1, -1 ),
287 new RecordType ( TypeCode.ParaFormatAtom, "ParaFormatAtom", false, true, -1, -1 ),
288 new RecordType ( TypeCode.RecolorInfoAtom, "RecolorInfoAtom", false, true, -1, -1 ),
289 new RecordType ( TypeCode.ExQuickTimeMovie, "ExQuickTimeMovie", true, true, -1, -1 ),
290 new RecordType ( TypeCode.ExQuickTimeMovieData, "ExQuickTimeMovieData", false, true, -1, -1 ),
291 new RecordType ( TypeCode.ExControl, "ExControl", true, true, -1, -1 ),
292 new RecordType ( TypeCode.SlideListWithText, "SlideListWithText", true, true, -1, -1 ),
293 new RecordType ( TypeCode.InteractiveInfo, "InteractiveInfo", true, true, -1, -1 ),
294 new RecordType ( TypeCode.InteractiveInfoAtom, "InteractiveInfoAtom", false, true, -1, -1 ),
295 new RecordType ( TypeCode.UserEditAtom, "UserEditAtom", false, true, -1, -1 ),
296 new RecordType ( TypeCode.CurrentUserAtom, "CurrentUserAtom", false, true, -1, -1 ),
297 new RecordType ( TypeCode.DateTimeMCAtom, "DateTimeMCAtom", false, true, -1, -1 ),
298 new RecordType ( TypeCode.GenericDateMCAtom, "GenericDateMCAtom", false, true, -1, -1 ),
299 new RecordType ( TypeCode.FooterMCAtom, "FooterMCAtom", false, true, -1, -1 ),
300 new RecordType ( TypeCode.ExControlAtom, "ExControlAtom", false, true, -1, -1 ),
301 new RecordType ( TypeCode.ExMediaAtom, "ExMediaAtom", false, true, -1, -1 ),
302 new RecordType ( TypeCode.ExVideo, "ExVideo", true, true, -1, -1 ),
303 new RecordType ( TypeCode.ExAviMovie, "ExAviMovie", true, true, -1, -1 ),
304 new RecordType ( TypeCode.ExMCIMovie, "ExMCIMovie", true, true, -1, -1 ),
305 new RecordType ( TypeCode.ExMIDIAudio, "ExMIDIAudio", true, true, -1, -1 ),
306 new RecordType ( TypeCode.ExCDAudio, "ExCDAudio", true, true, -1, -1 ),
307 new RecordType ( TypeCode.ExWAVAudioEmbedded, "ExWAVAudioEmbedded", true, true, -1, -1 ),
308 new RecordType ( TypeCode.ExWAVAudioLink, "ExWAVAudioLink", true, true, -1, -1 ),
309 new RecordType ( TypeCode.ExOleObjStg, "ExOleObjStg", false, true, -1, -1 ),
310 new RecordType ( TypeCode.ExCDAudioAtom, "ExCDAudioAtom", false, true, -1, -1 ),
311 new RecordType ( TypeCode.ExWAVAudioEmbeddedAtom, "ExWAVAudioEmbeddedAtom", false, true, -1, -1 ),
312 new RecordType ( TypeCode.AnimationInfoAtom, "AnimationInfoAtom", false, true, -1, -1 ),
313 new RecordType ( TypeCode.RTFDateTimeMCAtom, "RTFDateTimeMCAtom", false, true, -1, -1 ),
314 new RecordType ( TypeCode.ProgTags, "ProgTags", false, true, -1, -1 ), // don't know if container
315 new RecordType ( TypeCode.ProgStringTag, "ProgStringTag", true, true, -1, -1 ),
316 new RecordType ( TypeCode.ProgBinaryTag, "ProgBinaryTag", true, true, -1, -1 ),
317 new RecordType ( TypeCode.BinaryTagData, "BinaryTagData", false, true, -1, -1 ),
318 new RecordType ( TypeCode.PrintOptions, "PrintOptions", false, true, -1, -1 ),
319 new RecordType ( TypeCode.PersistPtrFullBlock, "PersistPtrFullBlock", false, true, -1, -1 ), // don't know if container
320 new RecordType ( TypeCode.PersistPtrIncrementalBlock, "PersistPtrIncrementalBlock", false, true, -1, -1 ),
321 new RecordType ( TypeCode.GScalingAtom, "GScalingAtom", false, true, -1, -1 ),
322 new RecordType ( TypeCode.GRColorAtom, "GRColorAtom", false, true, -1, -1 ),
324 new RecordType ( TypeCode.EscherDggContainer, "EscherDggContainer", true, true, -1, -1 ),
325 new RecordType ( TypeCode.EscherDgg, "EscherDgg", false, true, -1, -1 ),
326 new RecordType ( TypeCode.EscherCLSID, "EscherCLSID", false, true, -1, -1 ),
327 new RecordType ( TypeCode.EscherOPT, "EscherOPT", false, true, -1, -1 ),
328 new RecordType ( TypeCode.EscherBStoreContainer, "EscherBStoreContainer", true, true, -1, -1 ),
329 new RecordType ( TypeCode.EscherBSE, "EscherBSE", false, true, -1, -1 ),
330 new RecordType ( TypeCode.EscherBlip_START, "EscherBlip_START", false, true, -1, -1 ),
331 new RecordType ( TypeCode.EscherBlip_END, "EscherBlip_END", false, true, -1, -1 ),
332 new RecordType ( TypeCode.EscherDgContainer, "EscherDgContainer", true, true, -1, -1 ),
333 new RecordType ( TypeCode.EscherDg, "EscherDg", false, true, -1, -1 ),
334 new RecordType ( TypeCode.EscherRegroupItems, "EscherRegroupItems", false, true, -1, -1 ),
335 new RecordType ( TypeCode.EscherColorScheme, "EscherColorScheme", false, true, -1, -1 ),
336 new RecordType ( TypeCode.EscherSpgrContainer, "EscherSpgrContainer", true, true, -1, -1 ),
337 new RecordType ( TypeCode.EscherSpContainer, "EscherSpContainer", true, true, -1, -1 ),
338 new RecordType ( TypeCode.EscherSpgr, "EscherSpgr", false, true, -1, -1 ),
339 new RecordType ( TypeCode.EscherSp, "EscherSp", false, true, -1, -1 ),
340 new RecordType ( TypeCode.EscherTextbox, "EscherTextbox", false, true, -1, -1 ),
341 new RecordType ( TypeCode.EscherClientTextbox, "EscherClientTextbox", true, true, -1, -1 ),
342 new RecordType ( TypeCode.EscherAnchor, "EscherAnchor", false, true, -1, -1 ),
343 new RecordType ( TypeCode.EscherChildAnchor, "EscherChildAnchor", false, true, -1, -1 ),
344 new RecordType ( TypeCode.EscherClientAnchor, "EscherClientAnchor", false, true, -1, -1 ),
345 new RecordType ( TypeCode.EscherClientData, "EscherClientData", true, true, -1, -1 ),
346 new RecordType ( TypeCode.EscherSolverContainer, "EscherSolverContainer", true, true, -1, -1 ),
347 new RecordType ( TypeCode.EscherConnectorRule, "EscherConnectorRule", false, true, -1, -1 ),
348 new RecordType ( TypeCode.EscherAlignRule, "EscherAlignRule", false, true, -1, -1 ),
349 new RecordType ( TypeCode.EscherArcRule, "EscherArcRule", false, true, -1, -1 ),
350 new RecordType ( TypeCode.EscherClientRule, "EscherClientRule", false, true, -1, -1 ),
351 new RecordType ( TypeCode.EscherCalloutRule, "EscherCalloutRule", false, true, -1, -1 ),
352 new RecordType ( TypeCode.EscherSelection, "EscherSelection", false, true, -1, -1 ),
353 new RecordType ( TypeCode.EscherColorMRU, "EscherColorMRU", false, true, -1, -1 ),
354 new RecordType ( TypeCode.EscherDeletedPspl, "EscherDeletedPspl", false, true, -1, -1 ),
355 new RecordType ( TypeCode.EscherSplitMenuColors, "EscherSplitMenuColors", false, true, -1, -1 ),
356 new RecordType ( TypeCode.EscherOleObject, "EscherOleObject", false, true, -1, -1 ),
357 new RecordType ( TypeCode.EscherUserDefined, "EscherUserDefined", false, true, -1, -1 )
360 public static RecordType Find (TypeCode typecode)
362 for (int i = 0; i < types.Length; i++) {
363 if (types[i].typecode == typecode)
364 return types[i];
366 return types[0];
370 namespace Beagle.Filters {
372 public class FilterPPT : FilterOle {
374 bool read_text;
375 int slide_count;
377 public FilterPPT ()
379 AddSupportedMimeType ("application/vnd.ms-powerpoint");
382 private int ParseElement (Gsf.Input stream)
384 byte [] data = stream.Read(8);
385 if (data == null)
386 return 0;
387 RecordType.TypeCode opcode = (RecordType.TypeCode) GetInt16(data, 2);
388 int length = GetInt32(data, 4);
389 RecordType type = RecordType.Find (opcode);
390 if (type.is_container) {
391 int length_remaining = length;
392 if (opcode == RecordType.TypeCode.SlideListWithText) {
393 slide_count = 0;
395 while (length_remaining > 0) {
396 int elem_length = ParseElement(stream);
397 if (elem_length == 0)
398 return 0;
399 length_remaining -= elem_length;
401 } else {
402 if (length != 0) {
403 System.Text.Encoding encoding = null;
405 if (opcode == RecordType.TypeCode.TextBytesAtom) {
406 encoding = System.Text.Encoding.GetEncoding (28591);
407 } else if (opcode == RecordType.TypeCode.TextCharsAtom) {
408 encoding = System.Text.Encoding.Unicode;
409 } else if (opcode == RecordType.TypeCode.SlidePersistAtom) {
410 slide_count ++;
413 if (encoding != null && read_text) {
414 data = stream.Read(length);
415 if (data == null)
416 return 0;
417 AppendText (encoding.GetString (data));
418 AppendWhiteSpace ();
419 } else {
420 stream.Seek(length, SeekOrigin.Current);
424 return length + 8;
427 override protected void DoPullProperties ()
429 Input stream = file.ChildByName ("PowerPoint Document");
431 read_text = false;
432 ParseElement(stream);
433 AddProperty (Beagle.Property.New ("fixme:SlideCount", slide_count));
436 override protected void DoPull ()
438 read_text = true;
439 Input stream = file.ChildByName ("PowerPoint Document");
441 ParseElement(stream);
442 Finished();