Class: Origami::Adobe::PPKLite::Parser

Inherits:
Parser
  • Object
show all
Defined in:
lib/origami/parsers/ppklite.rb

Constant Summary

Constants inherited from Parser

Parser::VERBOSE_DEBUG, Parser::VERBOSE_INFO, Parser::VERBOSE_INSANE, Parser::VERBOSE_QUIET

Instance Attribute Summary

Attributes inherited from Parser

#options

Instance Method Summary collapse

Methods inherited from Parser

#initialize, #parse_object, #parse_trailer, #parse_xreftable, #target_data, #target_filename, #target_filesize

Constructor Details

This class inherits a constructor from Origami::Parser

Instance Method Details

#book_specialize_entries(addrbk) ⇒ Object

:nodoc:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/origami/parsers/ppklite.rb', line 50

def book_specialize_entries(addrbk) #:nodoc:
  addrbk.revisions.first.body.each_pair do |ref, obj|
    
    if obj.is_a?(Dictionary)
      
      if obj[:Type] == :Catalog
        
        o = Adobe::PPKLite::Catalog.new(obj)
        o.generation, o.no, o.file_offset = obj.generation, obj.no, obj.file_offset
        
        if o.PPK.is_a?(Dictionary) and o.PPK[:Type] == :PPK
          o.PPK = Adobe::PPKLite::PPK.new(o.PPK)
          
          if o.PPK.User.is_a?(Dictionary) and o.PPK.User[:Type] == :User
            o.PPK.User = Adobe::PPKLite::UserList.new(o.PPK.User)
          end
          
          if o.PPK.AddressBook.is_a?(Dictionary) and o.PPK.AddressBook[:Type] == :AddressBook
            o.PPK.AddressBook = Adobe::PPKLite::AddressList.new(o.PPK.AddressBook)
          end
        end
        
        addrbk.revisions.first.body[ref] = o
        
      elsif obj[:ABEType] == Adobe::PPKLite::Descriptor::USER
        o = Adobe::PPKLite::User.new(obj)
        o.generation, o.no, o.file_offset = obj.generation, obj.no, obj.file_offset
        
        addrbk.revisions.first.body[ref] = o
      elsif obj[:ABEType] == Adobe::PPKLite::Descriptor::CERTIFICATE
        o = Adobe::PPKLite::Certificate.new(obj)
        o.generation, o.no, o.file_offset = obj.generation, obj.no, obj.file_offset
        
        addrbk.revisions.first.body[ref] = o
      end

    end
  end
end

#parse(stream) ⇒ Object

:nodoc:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/origami/parsers/ppklite.rb', line 31

def parse(stream) #:nodoc:
  super

  addrbk = Adobe::PPKLite.new
  addrbk.header = Adobe::PPKLite::Header.parse(stream)
  @options[:callback].call(addrbk.header)
  
  loop do
    break if (object = parse_object).nil?
    addrbk << object
  end

  addrbk.revisions.first.xreftable = parse_xreftable
  addrbm.revisions.first.trailer = parse_trailer
  book_specialize_entries(addrbk)

  addrbk
end