4 // Copyright (C) 2004 Novell, Inc.
8 // Permission is hereby granted, free of charge, to any person obtaining a
9 // copy of this software and associated documentation files (the "Software"),
10 // to deal in the Software without restriction, including without limitation
11 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 // and/or sell copies of the Software, and to permit persons to whom the
13 // Software is furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 // DEALINGS IN THE SOFTWARE.
29 using System
.Collections
;
37 internal class RecordType
40 public enum TypeCode
{
50 SlidePersistAtom
= 1011,
51 SSlideLayoutAtom
= 1015,
53 SSSlideInfoAtom
= 1017,
58 SlideViewInfoAtom
= 1022,
63 DocRoutingSlip
= 1030,
64 OutlineViewInfo
= 1031,
65 SorterViewInfo
= 1032,
68 PPDrawingGroup
= 1035, //FIXME: Office Art File Format Docu
69 PPDrawing
= 1036, //FIXME: Office Art File Format Docu
70 NamedShows
= 1040, // don't know if container
72 NamedShowSlides
= 1042, // don't know if container
74 FontCollection
= 2005,
75 BookmarkCollection
= 2019,
79 BookmarkSeedAtom
= 2025,
80 ColorSchemeAtom
= 2032,
83 OEPlaceholderAtom
= 3011,
86 OutlineTextRefAtom
= 3998,
87 TextHeaderAtom
= 3999,
89 StyleTextPropAtom
= 4001,
90 BaseTextPropAtom
= 4002,
91 TxMasterStyleAtom
= 4003,
95 TextBookmarkAtom
= 4007,
98 TextSpecInfoAtom
= 4010,
99 DefaultRulerAtom
= 4011,
100 FontEntityAtom
= 4023,
101 FontEmbeddedData
= 4024,
110 BookmarkEntityAtom
= 4048,
112 SrKinsokuAtom
= 4050,
113 ExHyperlinkAtom
= 4051,
115 SlideNumberMCAtom
= 4056,
116 HeadersFooters
= 4057,
117 HeadersFootersAtom
= 4058,
118 TxInteractiveInfoAtom
= 4063,
119 CharFormatAtom
= 4066,
120 ParaFormatAtom
= 4067,
121 RecolorInfoAtom
= 4071,
122 ExQuickTimeMovie
= 4074,
123 ExQuickTimeMovieData
= 4075,
125 SlideListWithText
= 4080,
126 InteractiveInfo
= 4082,
127 InteractiveInfoAtom
= 4083,
129 CurrentUserAtom
= 4086,
130 DateTimeMCAtom
= 4087,
131 GenericDateMCAtom
= 4088,
133 ExControlAtom
= 4091,
140 ExWAVAudioEmbedded
= 4111,
141 ExWAVAudioLink
= 4112,
143 ExCDAudioAtom
= 4114,
144 ExWAVAudioEmbeddedAtom
= 4115,
145 AnimationInfoAtom
= 4116,
146 RTFDateTimeMCAtom
= 4117,
147 ProgTags
= 5000, // don't know if container
148 ProgStringTag
= 5001,
149 ProgBinaryTag
= 5002,
150 BinaryTagData
= 5003,
152 PersistPtrFullBlock
= 6001, // don't know if container
153 PersistPtrIncrementalBlock
= 6002, // don't know if container
154 GScalingAtom
= 10001,
156 EscherDggContainer
= 0xf000, /* Drawing Group Container */
158 EscherCLSID
= 0xf016,
160 EscherBStoreContainer
= 0xf001,
162 EscherBlip_START
= 0xf018, /* Blip types are between */
163 EscherBlip_END
= 0xf117, /* these two values */
164 EscherDgContainer
= 0xf002, /* Drawing Container */
166 EscherRegroupItems
= 0xf118,
167 EscherColorScheme
= 0xf120, /* bug in docs */
168 EscherSpgrContainer
= 0xf003,
169 EscherSpContainer
= 0xf004,
172 EscherTextbox
= 0xf00c,
173 EscherClientTextbox
= 0xf00d,
174 EscherAnchor
= 0xf00e,
175 EscherChildAnchor
= 0xf00f,
176 EscherClientAnchor
= 0xf010,
177 EscherClientData
= 0xf011,
178 EscherSolverContainer
= 0xf005,
179 EscherConnectorRule
= 0xf012, /* bug in docs */
180 EscherAlignRule
= 0xf013,
181 EscherArcRule
= 0xf014,
182 EscherClientRule
= 0xf015,
183 EscherCalloutRule
= 0xf017,
184 EscherSelection
= 0xf119,
185 EscherColorMRU
= 0xf11a,
186 EscherDeletedPspl
= 0xf11d, /* bug in docs */
187 EscherSplitMenuColors
= 0xf11e,
188 EscherOleObject
= 0xf11f,
189 EscherUserDefined
= 0xf122,
192 public TypeCode typecode
;
194 public bool is_container
;
196 public int min_record_size
;
197 public int max_record_size
;
198 RecordType (TypeCode typecode
, string name
, bool is_container
, bool do_read
, int min_record_size
, int max_record_size
)
200 this.typecode
= typecode
;
202 this.is_container
= is_container
;
203 this.do_read
= do_read
;
204 this.min_record_size
= min_record_size
;
205 this.max_record_size
= max_record_size
;
208 static RecordType
[] types
=
210 new RecordType ( TypeCode
.Unknown
, "Unknown", false, true, -1, -1 ),
211 new RecordType ( TypeCode
.Document
, "Document", true, true, -1, -1 ),
212 new RecordType ( TypeCode
.DocumentAtom
, "DocumentAtom", false, true, -1, -1 ),
213 new RecordType ( TypeCode
.EndDocument
, "EndDocument", false, true, -1, -1 ),
214 new RecordType ( TypeCode
.Slide
, "Slide", true, true, -1, -1 ),
215 new RecordType ( TypeCode
.SlideAtom
, "SlideAtom", false, true, -1, -1 ),
216 new RecordType ( TypeCode
.Notes
, "Notes", true, true, -1, -1 ),
217 new RecordType ( TypeCode
.NotesAtom
, "NotesAtom", false, true, -1, -1 ),
218 new RecordType ( TypeCode
.Environment
, "Environment", true, true, -1, -1 ),
219 new RecordType ( TypeCode
.SlidePersistAtom
, "SlidePersistAtom", false, true, -1, -1 ),
220 new RecordType ( TypeCode
.SSlideLayoutAtom
, "SSlideLayoutAtom", false, true, -1, -1 ),
221 new RecordType ( TypeCode
.MainMaster
, "MainMaster", true, true, -1, -1 ),
222 new RecordType ( TypeCode
.SSSlideInfoAtom
, "SSSlideInfoAtom", false, true, -1, -1 ),
223 new RecordType ( TypeCode
.SlideViewInfo
, "SlideViewInfo", true, true, -1, -1 ),
224 new RecordType ( TypeCode
.GuideAtom
, "GuideAtom", false, true, -1, -1 ),
225 new RecordType ( TypeCode
.ViewInfo
, "ViewInfo", true, true, -1, -1 ),
226 new RecordType ( TypeCode
.ViewInfoAtom
, "ViewInfoAtom", false, true, -1, -1 ),
227 new RecordType ( TypeCode
.SlideViewInfoAtom
, "SlideViewInfoAtom", false, true, -1, -1 ),
228 new RecordType ( TypeCode
.VBAInfo
, "VBAInfo", true, true, -1, -1 ),
229 new RecordType ( TypeCode
.VBAInfoAtom
, "VBAInfoAtom", false, true, -1, -1 ),
230 new RecordType ( TypeCode
.SSDocInfoAtom
, "SSDocInfoAtom", false, true, -1, -1 ),
231 new RecordType ( TypeCode
.Summary
, "Summary", true, true, -1, -1 ),
232 new RecordType ( TypeCode
.DocRoutingSlip
, "DocRoutingSlip", false, true, -1, -1 ),
233 new RecordType ( TypeCode
.OutlineViewInfo
, "OutlineViewInfo", true, true, -1, -1 ),
234 new RecordType ( TypeCode
.SorterViewInfo
, "SorterViewInfo", true, true, -1, -1 ),
235 new RecordType ( TypeCode
.ExObjList
, "ExObjList", true, true, -1, -1 ),
236 new RecordType ( TypeCode
.ExObjListAtom
, "ExObjListAtom", false, true, -1, -1 ),
237 new RecordType ( TypeCode
.PPDrawingGroup
, "PPDrawingGroup", true, true, -1, -1 ), //FIXME: Office Art File Format Docu
238 new RecordType ( TypeCode
.PPDrawing
, "PPDrawing", true, true, -1, -1 ), //FIXME: Office Art File Format Docu
239 new RecordType ( TypeCode
.NamedShows
, "NamedShows", false, true, -1, -1 ), // don't know if container
240 new RecordType ( TypeCode
.NamedShow
, "NamedShow", true, true, -1, -1 ),
241 new RecordType ( TypeCode
.NamedShowSlides
, "NamedShowSlides", false, true, -1, -1 ), // don't know if container
242 new RecordType ( TypeCode
.List
, "List", true, true, -1, -1 ),
243 new RecordType ( TypeCode
.FontCollection
, "FontCollection", true, true, -1, -1 ),
244 new RecordType ( TypeCode
.BookmarkCollection
, "BookmarkCollection", true, true, -1, -1 ),
245 new RecordType ( TypeCode
.SoundCollAtom
, "SoundCollAtom", false, true, -1, -1 ),
246 new RecordType ( TypeCode
.Sound
, "Sound", true, true, -1, -1 ),
247 new RecordType ( TypeCode
.SoundData
, "SoundData", false, true, -1, -1 ),
248 new RecordType ( TypeCode
.BookmarkSeedAtom
, "BookmarkSeedAtom", false, true, -1, -1 ),
249 new RecordType ( TypeCode
.ColorSchemeAtom
, "ColorSchemeAtom", false, true, -1, -1 ),
250 new RecordType ( TypeCode
.ExObjRefAtom
, "ExObjRefAtom", false, true, -1, -1 ),
251 new RecordType ( TypeCode
.OEShapeAtom
, "OEShapeAtom", false, true, -1, -1 ),
252 new RecordType ( TypeCode
.OEPlaceholderAtom
, "OEPlaceholderAtom", false, true, -1, -1 ),
253 new RecordType ( TypeCode
.GPointAtom
, "GPointAtom", false, true, -1, -1 ),
254 new RecordType ( TypeCode
.GRatioAtom
, "GRatioAtom", false, true, -1, -1 ),
255 new RecordType ( TypeCode
.OutlineTextRefAtom
, "OutlineTextRefAtom", false, true, -1, -1 ),
256 new RecordType ( TypeCode
.TextHeaderAtom
, "TextHeaderAtom", false, true, -1, -1 ),
257 new RecordType ( TypeCode
.TextCharsAtom
, "TextCharsAtom", false, true, -1, -1 ),
258 new RecordType ( TypeCode
.StyleTextPropAtom
, "StyleTextPropAtom", false, true, -1, -1 ),
259 new RecordType ( TypeCode
.BaseTextPropAtom
, "BaseTextPropAtom", false, true, -1, -1 ),
260 new RecordType ( TypeCode
.TxMasterStyleAtom
, "TxMasterStyleAtom", false, true, -1, -1 ),
261 new RecordType ( TypeCode
.TxCFStyleAtom
, "TxCFStyleAtom", false, true, -1, -1 ),
262 new RecordType ( TypeCode
.TxPFStyleAtom
, "TxPFStyleAtom", false, true, -1, -1 ),
263 new RecordType ( TypeCode
.TextRulerAtom
, "TextRulerAtom", false, true, -1, -1 ),
264 new RecordType ( TypeCode
.TextBookmarkAtom
, "TextBookmarkAtom", false, true, -1, -1 ),
265 new RecordType ( TypeCode
.TextBytesAtom
, "TextBytesAtom", false, true, -1, -1 ),
266 new RecordType ( TypeCode
.TxSIStyleAtom
, "TxSIStyleAtom", false, true, -1, -1 ),
267 new RecordType ( TypeCode
.TextSpecInfoAtom
, "TextSpecInfoAtom", false, true, -1, -1 ),
268 new RecordType ( TypeCode
.DefaultRulerAtom
, "DefaultRulerAtom", false, true, -1, -1 ),
269 new RecordType ( TypeCode
.FontEntityAtom
, "FontEntityAtom", false, true, -1, -1 ),
270 new RecordType ( TypeCode
.FontEmbeddedData
, "FontEmbeddedData", false, true, -1, -1 ),
271 new RecordType ( TypeCode
.CString
, "CString", false, true, -1, -1 ),
272 new RecordType ( TypeCode
.MetaFile
, "MetaFile", false, true, -1, -1 ),
273 new RecordType ( TypeCode
.ExOleObjAtom
, "ExOleObjAtom", false, true, -1, -1 ),
274 new RecordType ( TypeCode
.SrKinsoku
, "SrKinsoku", true, true, -1, -1 ),
275 new RecordType ( TypeCode
.HandOut
, "HandOut", true, true, -1, -1 ),
276 new RecordType ( TypeCode
.ExEmbed
, "ExEmbed", true, true, -1, -1 ),
277 new RecordType ( TypeCode
.ExEmbedAtom
, "ExEmbedAtom", false, true, -1, -1 ),
278 new RecordType ( TypeCode
.ExLink
, "ExLink", true, true, -1, -1 ),
279 new RecordType ( TypeCode
.BookmarkEntityAtom
, "BookmarkEntityAtom", false, true, -1, -1 ),
280 new RecordType ( TypeCode
.ExLinkAtom
, "ExLinkAtom", false, true, -1, -1 ),
281 new RecordType ( TypeCode
.SrKinsokuAtom
, "SrKinsokuAtom", false, true, -1, -1 ),
282 new RecordType ( TypeCode
.ExHyperlinkAtom
, "ExHyperlinkAtom", false, true, -1, -1 ),
283 new RecordType ( TypeCode
.ExHyperlink
, "ExHyperlink", true, true, -1, -1 ),
284 new RecordType ( TypeCode
.SlideNumberMCAtom
, "SlideNumberMCAtom", false, true, -1, -1 ),
285 new RecordType ( TypeCode
.HeadersFooters
, "HeadersFooters", true, true, -1, -1 ),
286 new RecordType ( TypeCode
.HeadersFootersAtom
, "HeadersFootersAtom", false, true, -1, -1 ),
287 new RecordType ( TypeCode
.TxInteractiveInfoAtom
, "TxInteractiveInfoAtom", false, true, -1, -1 ),
288 new RecordType ( TypeCode
.CharFormatAtom
, "CharFormatAtom", false, true, -1, -1 ),
289 new RecordType ( TypeCode
.ParaFormatAtom
, "ParaFormatAtom", false, true, -1, -1 ),
290 new RecordType ( TypeCode
.RecolorInfoAtom
, "RecolorInfoAtom", false, true, -1, -1 ),
291 new RecordType ( TypeCode
.ExQuickTimeMovie
, "ExQuickTimeMovie", true, true, -1, -1 ),
292 new RecordType ( TypeCode
.ExQuickTimeMovieData
, "ExQuickTimeMovieData", false, true, -1, -1 ),
293 new RecordType ( TypeCode
.ExControl
, "ExControl", true, true, -1, -1 ),
294 new RecordType ( TypeCode
.SlideListWithText
, "SlideListWithText", true, true, -1, -1 ),
295 new RecordType ( TypeCode
.InteractiveInfo
, "InteractiveInfo", true, true, -1, -1 ),
296 new RecordType ( TypeCode
.InteractiveInfoAtom
, "InteractiveInfoAtom", false, true, -1, -1 ),
297 new RecordType ( TypeCode
.UserEditAtom
, "UserEditAtom", false, true, -1, -1 ),
298 new RecordType ( TypeCode
.CurrentUserAtom
, "CurrentUserAtom", false, true, -1, -1 ),
299 new RecordType ( TypeCode
.DateTimeMCAtom
, "DateTimeMCAtom", false, true, -1, -1 ),
300 new RecordType ( TypeCode
.GenericDateMCAtom
, "GenericDateMCAtom", false, true, -1, -1 ),
301 new RecordType ( TypeCode
.FooterMCAtom
, "FooterMCAtom", false, true, -1, -1 ),
302 new RecordType ( TypeCode
.ExControlAtom
, "ExControlAtom", false, true, -1, -1 ),
303 new RecordType ( TypeCode
.ExMediaAtom
, "ExMediaAtom", false, true, -1, -1 ),
304 new RecordType ( TypeCode
.ExVideo
, "ExVideo", true, true, -1, -1 ),
305 new RecordType ( TypeCode
.ExAviMovie
, "ExAviMovie", true, true, -1, -1 ),
306 new RecordType ( TypeCode
.ExMCIMovie
, "ExMCIMovie", true, true, -1, -1 ),
307 new RecordType ( TypeCode
.ExMIDIAudio
, "ExMIDIAudio", true, true, -1, -1 ),
308 new RecordType ( TypeCode
.ExCDAudio
, "ExCDAudio", true, true, -1, -1 ),
309 new RecordType ( TypeCode
.ExWAVAudioEmbedded
, "ExWAVAudioEmbedded", true, true, -1, -1 ),
310 new RecordType ( TypeCode
.ExWAVAudioLink
, "ExWAVAudioLink", true, true, -1, -1 ),
311 new RecordType ( TypeCode
.ExOleObjStg
, "ExOleObjStg", false, true, -1, -1 ),
312 new RecordType ( TypeCode
.ExCDAudioAtom
, "ExCDAudioAtom", false, true, -1, -1 ),
313 new RecordType ( TypeCode
.ExWAVAudioEmbeddedAtom
, "ExWAVAudioEmbeddedAtom", false, true, -1, -1 ),
314 new RecordType ( TypeCode
.AnimationInfoAtom
, "AnimationInfoAtom", false, true, -1, -1 ),
315 new RecordType ( TypeCode
.RTFDateTimeMCAtom
, "RTFDateTimeMCAtom", false, true, -1, -1 ),
316 new RecordType ( TypeCode
.ProgTags
, "ProgTags", false, true, -1, -1 ), // don't know if container
317 new RecordType ( TypeCode
.ProgStringTag
, "ProgStringTag", true, true, -1, -1 ),
318 new RecordType ( TypeCode
.ProgBinaryTag
, "ProgBinaryTag", true, true, -1, -1 ),
319 new RecordType ( TypeCode
.BinaryTagData
, "BinaryTagData", false, true, -1, -1 ),
320 new RecordType ( TypeCode
.PrintOptions
, "PrintOptions", false, true, -1, -1 ),
321 new RecordType ( TypeCode
.PersistPtrFullBlock
, "PersistPtrFullBlock", false, true, -1, -1 ), // don't know if container
322 new RecordType ( TypeCode
.PersistPtrIncrementalBlock
, "PersistPtrIncrementalBlock", false, true, -1, -1 ),
323 new RecordType ( TypeCode
.GScalingAtom
, "GScalingAtom", false, true, -1, -1 ),
324 new RecordType ( TypeCode
.GRColorAtom
, "GRColorAtom", false, true, -1, -1 ),
326 new RecordType ( TypeCode
.EscherDggContainer
, "EscherDggContainer", true, true, -1, -1 ),
327 new RecordType ( TypeCode
.EscherDgg
, "EscherDgg", false, true, -1, -1 ),
328 new RecordType ( TypeCode
.EscherCLSID
, "EscherCLSID", false, true, -1, -1 ),
329 new RecordType ( TypeCode
.EscherOPT
, "EscherOPT", false, true, -1, -1 ),
330 new RecordType ( TypeCode
.EscherBStoreContainer
, "EscherBStoreContainer", true, true, -1, -1 ),
331 new RecordType ( TypeCode
.EscherBSE
, "EscherBSE", false, true, -1, -1 ),
332 new RecordType ( TypeCode
.EscherBlip_START
, "EscherBlip_START", false, true, -1, -1 ),
333 new RecordType ( TypeCode
.EscherBlip_END
, "EscherBlip_END", false, true, -1, -1 ),
334 new RecordType ( TypeCode
.EscherDgContainer
, "EscherDgContainer", true, true, -1, -1 ),
335 new RecordType ( TypeCode
.EscherDg
, "EscherDg", false, true, -1, -1 ),
336 new RecordType ( TypeCode
.EscherRegroupItems
, "EscherRegroupItems", false, true, -1, -1 ),
337 new RecordType ( TypeCode
.EscherColorScheme
, "EscherColorScheme", false, true, -1, -1 ),
338 new RecordType ( TypeCode
.EscherSpgrContainer
, "EscherSpgrContainer", true, true, -1, -1 ),
339 new RecordType ( TypeCode
.EscherSpContainer
, "EscherSpContainer", true, true, -1, -1 ),
340 new RecordType ( TypeCode
.EscherSpgr
, "EscherSpgr", false, true, -1, -1 ),
341 new RecordType ( TypeCode
.EscherSp
, "EscherSp", false, true, -1, -1 ),
342 new RecordType ( TypeCode
.EscherTextbox
, "EscherTextbox", false, true, -1, -1 ),
343 new RecordType ( TypeCode
.EscherClientTextbox
, "EscherClientTextbox", true, true, -1, -1 ),
344 new RecordType ( TypeCode
.EscherAnchor
, "EscherAnchor", false, true, -1, -1 ),
345 new RecordType ( TypeCode
.EscherChildAnchor
, "EscherChildAnchor", false, true, -1, -1 ),
346 new RecordType ( TypeCode
.EscherClientAnchor
, "EscherClientAnchor", false, true, -1, -1 ),
347 new RecordType ( TypeCode
.EscherClientData
, "EscherClientData", true, true, -1, -1 ),
348 new RecordType ( TypeCode
.EscherSolverContainer
, "EscherSolverContainer", true, true, -1, -1 ),
349 new RecordType ( TypeCode
.EscherConnectorRule
, "EscherConnectorRule", false, true, -1, -1 ),
350 new RecordType ( TypeCode
.EscherAlignRule
, "EscherAlignRule", false, true, -1, -1 ),
351 new RecordType ( TypeCode
.EscherArcRule
, "EscherArcRule", false, true, -1, -1 ),
352 new RecordType ( TypeCode
.EscherClientRule
, "EscherClientRule", false, true, -1, -1 ),
353 new RecordType ( TypeCode
.EscherCalloutRule
, "EscherCalloutRule", false, true, -1, -1 ),
354 new RecordType ( TypeCode
.EscherSelection
, "EscherSelection", false, true, -1, -1 ),
355 new RecordType ( TypeCode
.EscherColorMRU
, "EscherColorMRU", false, true, -1, -1 ),
356 new RecordType ( TypeCode
.EscherDeletedPspl
, "EscherDeletedPspl", false, true, -1, -1 ),
357 new RecordType ( TypeCode
.EscherSplitMenuColors
, "EscherSplitMenuColors", false, true, -1, -1 ),
358 new RecordType ( TypeCode
.EscherOleObject
, "EscherOleObject", false, true, -1, -1 ),
359 new RecordType ( TypeCode
.EscherUserDefined
, "EscherUserDefined", false, true, -1, -1 )
362 public static RecordType
Find (TypeCode typecode
)
364 for (int i
= 0; i
< types
.Length
; i
++) {
365 if (types
[i
].typecode
== typecode
)
372 namespace Beagle
.Filters
{
374 public class FilterPPT
: FilterOle
{
376 private enum TextType
{
392 AddSupportedFlavor (FilterFlavor
.NewFromMimeType ("application/vnd.ms-powerpoint"));
393 textType
= TextType
.Invalid
;
399 private int ParseElement (Input stream
)
401 int data_remaining
= (int) stream
.Remaining
;
402 //Console.WriteLine ("stream.Remaining = {0}", data_remaining);
404 // Weird!! Well, Its a M$ format ;-)
406 byte [] data
= stream
.Read (data_remaining
> 7 ? 8 : data_remaining
);
407 if (data
== null || data_remaining
< 8)
410 RecordType
.TypeCode opcode
= (RecordType
.TypeCode
) GetInt16(data
, 2);
411 int length
= GetInt32(data
, 4);
412 RecordType type
= RecordType
.Find (opcode
);
414 // Process the container tree
415 if (type
.is_container
) {
416 int length_remaining
= length
;
418 if (opcode
== RecordType
.TypeCode
.MainMaster
) {
419 // Ignore MainMaster container as it contains
420 // just a master-slide view and no user data.
421 stream
.Seek (length_remaining
, SeekOrigin
.Current
);
423 while (length_remaining
> 0) {
424 int elem_length
= ParseElement(stream
);
425 if (elem_length
== 0)
427 length_remaining
-= elem_length
;
428 //Console.WriteLine ("ParseElement: length = {0}, rem = {1}",
429 // elem_length, length_remaining);
434 System
.Text
.Encoding encoding
= null;
436 if (opcode
== RecordType
.TypeCode
.TextBytesAtom
) {
437 //encoding = System.Text.Encoding.GetEncoding (28591);
438 encoding
= System
.Text
.Encoding
.UTF8
;
439 } else if (opcode
== RecordType
.TypeCode
.TextCharsAtom
) {
440 encoding
= System
.Text
.Encoding
.Unicode
;
443 if (encoding
!= null && textType
!= TextType
.NotUsed
) {
444 StringBuilder strData
= new StringBuilder () ;
445 data
= stream
.Read(length
);
448 // Replace all ^M with "whitespace",
449 // because of which the contents were not properly
450 // been appended to the text pool.
451 strData
.Append (encoding
.GetString (data
).Replace ('\r', ' '));
453 // Replace all ^K with "whitespace",
454 // because of which the contents were not properly
455 // been appended to the text pool.
456 strData
.Replace ((char)0x0B, (char)0x20);
458 if (textType
== TextType
.Title
||
459 textType
== TextType
.CenterBody
||
460 textType
== TextType
.CenterTitle
)
462 AppendText (strData
.ToString());
466 AppendStructuralBreak ();
467 //Console.WriteLine ("Text : {0}", strData);
468 } else if (opcode
== RecordType
.TypeCode
.TextHeaderAtom
) {
469 data
= stream
.Read (4);
470 textType
= (TextType
) GetInt32 (data
, 0);
472 stream
.Seek(length
, SeekOrigin
.Current
);
477 // length = RecordHeader.recLen
478 // 8 = sizeof (RecordHeader)
479 // Every Atom/container is preceded by a RecordHeader
484 override protected void ExtractMetaData (Input sumStream
, Input docSumStream
)
489 if (docSumMeta
!= null) {
490 prop
= docSumMeta
.Lookup ("gsf:slide-count");
492 slide_count
= (int) prop
.Val
;
494 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:slide-count", slide_count
));
498 override protected void DoPull ()
507 stream
= file
.ChildByName ("PowerPoint Document");
509 if (stream
!= null) {
511 // The parsing was getting terminated when "EndDocument"
512 // container was parsed. We need to continue our
513 // parsing till the end of the file, since, some of the
514 // slides do persist after the actual "Document"
516 // PPTs exported from OO.o actually writes almost all the slides
517 // after "Document" container.
518 // And certain PPTs do have some slides in after
519 // "Document" container.
520 //Console.WriteLine ("Length of stream = {0}", stream.Size);
521 while (!stream
.Eof
) {
522 ParseElement (stream
);
523 //Console.WriteLine ("Position of the ptr in the stream: {0}", stream.Position);
526 Logger
.Log
.Error ("Ole stream not found in {0}. Content extraction skipped.", FileName
);
530 } catch (Exception e
) {
531 Logger
.Log
.Error ("Exception {0} occurred during DoPull.", e
.Message
);
536 override protected void OpenStorage (FileInfo info
)
538 FileName
= info
.FullName
;
540 // PPT 95/97-2000 format contains a "PP97_DUALSTORAGE", which is required
541 // to index PPT 97-2000 files.
542 // We don't support PPT 95 files, however, we happily accept patches ;-)
544 Input dualStorTemp
= null;
546 if ((dualStorTemp
= file
.ChildByName ("PP97_DUALSTORAGE")) != null) {
547 // "PP97_DUALSTORAGE" is a storage containing some streams
548 if (dualStorTemp
.Handle
!= IntPtr
.Zero
)
549 file
= (Gsf
.Infile
) GLib
.Object
.GetObject (dualStorTemp
.Handle
);
550 } else if (((dualStorTemp
= file
.ChildByName ("Header")) != null) ||
551 ((dualStorTemp
= file
.ChildByName ("PowerPoint Document")) == null)) {
552 Logger
.Log
.Error ("{0} is a PPT 95/4.0 file. Beagle does not support PPT 95 files. Skipping...", FileName
);
555 } catch (Exception e
) {
557 Logger
.Log
.Error ("Unable to open OleFile stream of "+info
.FullName
);