Class: RubyXL::ContentTypes

Inherits:
OOXMLTopLevelObject show all
Defined in:
lib/rubyXL/objects/content_types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OOXMLTopLevelObject

#add_to_zip, #attach_relationship, define_relationship, #file_index, parse_file, set_namespaces

Methods included from OOXMLObjectClassMethods

#define_attribute, #define_child_node, #define_element_name, #obtain_class_variable, #parse

Methods included from OOXMLObjectInstanceMethods

#dup, #index_in_collection, #initialize, #write_xml

Instance Attribute Details

#ownerObject

Returns the value of attribute owner.



18
19
20
# File 'lib/rubyXL/objects/content_types.rb', line 18

def owner
  @owner
end

Class Method Details

.save_orderObject



34
35
36
# File 'lib/rubyXL/objects/content_types.rb', line 34

def self.save_order
  999  # Must be saved last, so it has time to accumulate overrides from all others.
end

.xlsx_pathObject



26
27
28
# File 'lib/rubyXL/objects/content_types.rb', line 26

def self.xlsx_path
  '[Content_Types].xml'
end

Instance Method Details

#add_override(obj) ⇒ Object



38
39
40
41
# File 'lib/rubyXL/objects/content_types.rb', line 38

def add_override(obj)
  return unless obj.class.const_defined?(:CONTENT_TYPE)
  overrides << RubyXL::ContentTypeOverride.new(:part_name => "/#{obj.xlsx_path}", :content_type => obj.class::CONTENT_TYPE)
end

#before_write_xmlObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rubyXL/objects/content_types.rb', line 43

def before_write_xml
  self.defaults = []
  if owner.rels_hash[RubyXL::PrinterSettingsFile] then
    defaults << RubyXL::ContentTypeDefault.new(:extension => 'bin',
                  :content_type => 'application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings')
  end

  defaults << RubyXL::ContentTypeDefault.new(:extension => 'rels',
                  :content_type => 'application/vnd.openxmlformats-package.relationships+xml' )

  defaults << RubyXL::ContentTypeDefault.new(:extension => 'xml',
                  :content_type => 'application/xml' )

  # TODO: Need to only write these types when respective content is actually present.
  defaults << RubyXL::ContentTypeDefault.new(:extension => 'jpeg', :content_type => 'image/jpeg')
  defaults << RubyXL::ContentTypeDefault.new(:extension => 'png', :content_type => 'image/png')
  defaults << RubyXL::ContentTypeDefault.new(:extension => 'wmf', :content_type => 'image/x-wmf')
  defaults << RubyXL::ContentTypeDefault.new(:extension => 'vml', :content_type => 'application/vnd.openxmlformats-officedocument.vmlDrawing')

  true
end

#xlsx_pathObject



30
31
32
# File 'lib/rubyXL/objects/content_types.rb', line 30

def xlsx_path
  self.class.xlsx_path
end