Method: RubyXL::OOXMLRelationshipsFile#load_related_files

Defined in:
lib/rubyXL/objects/relationships.rb

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/rubyXL/objects/relationships.rb', line 70

def load_related_files(zipdir_path, base_file_name)
  self.related_files = {}

  @@debug_indent += 2 if @@debug_indent

  self.relationships.each { |rel|
    next if rel.target_mode == 'External'

    file_path = ::Pathname.new(rel.target)
    file_path = (base_file_name.dirname + file_path).cleanpath if file_path.relative?

    klass = RubyXL::OOXMLRelationshipsFile.get_class_by_rel_type(rel.type)

    if klass.nil? then
      if !RubyXL.class_variable_get(:@@suppress_warnings) then
        puts "*** WARNING: storage class not found for #{rel.target} (#{rel.type})"
      end

      klass = GenericStorageObject
    end

    puts "--> DEBUG:#{'  ' * @@debug_indent}Loading #{klass} (#{rel.id}): #{file_path}" if @@debug_indent

    obj = klass.parse_file(zipdir_path, file_path)
    obj.load_relationships(zipdir_path, file_path) if obj.respond_to?(:load_relationships)
    self.related_files[rel.id] = obj
  }

  @@debug_indent -= 2 if @@debug_indent

  related_files
end