Class: ODFWriter::Style
- Inherits:
-
Object
- Object
- ODFWriter::Style
- Defined in:
- lib/odf_writer/style.rb
Overview
Style: add styles to styles.xml
Constant Summary collapse
- DOC_STYLES =
constants
[:h1, :h2, :h3, :h4, :h5, :h6, # header style :paragraph, :subparagraph, :redmine # paragraph style ]
- AUT_STYLES =
character style
[:bold, :underline, :italic, :strikethrough, # character style :sub, :sup, :code, :a, :large, :medium, :small, # character style :center, :left, :right, :justify, # paragraph style :p, :mono, :monoright, :monocenter, :cling, # paragraph style :quote, :pre, # paragraph style :table, :thrifty, :tiny, :list, :listmedium, # table style :invoice, :boxes, :caption, # table style :tr, :td, :tdbott, :tdbox, :tdhead, :tdfoot, # table content style :tc, :tcnarrow, :tcwide, :tcfixed, :tcauto # table content style ]
- LIST_STYLES =
[:ul, :ol]
Instance Method Summary collapse
-
#add_automatic_style(doc) ⇒ Object
add_style.
-
#add_document_style(doc) ⇒ Object
add_style.
-
#initialize(*styles) ⇒ Style
constructor
initialize.
Constructor Details
#initialize(*styles) ⇒ Style
initialize
61 62 63 64 |
# File 'lib/odf_writer/style.rb', line 61 def initialize( *styles ) @styles = *styles @font = {} end |
Instance Method Details
#add_automatic_style(doc) ⇒ Object
add_style
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/odf_writer/style.rb', line 72 def add_automatic_style( doc ) ns = doc.collect_namespaces automatic_styles = doc.at("//office:automatic-styles", ns) font_declarations = doc.at("//office:font-face-decls", ns) @styles.each do |style| @font = nil # will be set in create_style automatic_styles << create_style( doc, style ) if automatic_styles.present? if @font.present? font_declarations << create_font( doc, @font ) if font_declarations.present? end end end |
#add_document_style(doc) ⇒ Object
add_style
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/odf_writer/style.rb', line 94 def add_document_style( doc ) ns = doc.collect_namespaces automatic_styles = doc.at("//office:document-styles", ns) font_declarations = doc.at("//office:font-face-decls", ns) @styles.each do |style| @font = nil # will be set in create_style automatic_styles << create_style( doc, style ) if automatic_styles.present? if @font.present? font_declarations << create_font( doc, @font ) if font_declarations.present? end end end |