Module: Uniword::ContentTypes
- Defined in:
- lib/uniword/content_types.rb,
lib/uniword/content_types/types.rb,
lib/uniword/content_types/default.rb,
lib/uniword/content_types/override.rb
Defined Under Namespace
Classes: Default, Override, Types
Class Method Summary collapse
-
.generate ⇒ Types
Generates [Content_Types].xml for DOCX packages This content tells Office what kind of content each part contains.
-
.generate_for_theme ⇒ Types
Generate [Content_Types].xml for THMX (theme) packages.
Class Method Details
.generate ⇒ Types
Generates [Content_Types].xml for DOCX packages This content tells Office what kind of content each part contains
Generate comprehensive [Content_Types].xml
Derived from Ooxml::PartRegistry (:standard definitions, in registration order — historically the literal order below).
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/uniword/content_types.rb', line 23 def generate Types.new( defaults: Ooxml::PartRegistry.standard_defaults.map do |defn| Default.new(extension: defn.extension, content_type: defn.content_type) end, overrides: Ooxml::PartRegistry.standard_overrides.map do |defn| Override.new(part_name: defn.part_name, content_type: defn.content_type) end, ) end |
.generate_for_theme ⇒ Types
Generate [Content_Types].xml for THMX (theme) packages
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/uniword/content_types.rb', line 40 def generate_for_theme theme = Ooxml::PartRegistry.find_by_key(:thmx_theme) Types.new( defaults: %i[rels xml].map do |key| defn = Ooxml::PartRegistry.find_by_key(key) Default.new(extension: defn.extension, content_type: defn.content_type) end, overrides: [ Override.new(part_name: theme.part_name, content_type: theme.content_type), ], ) end |