class OpenXml::Docx::Parts::Styles

Attributes

styles[R]

Public Class Methods

new() click to toggle source
# File lib/openxml/docx/parts/styles.rb, line 11
def initialize
  @styles = []
end

Public Instance Methods

<<(style) click to toggle source
# File lib/openxml/docx/parts/styles.rb, line 15
def <<(style)
  @styles << style
end
to_xml() click to toggle source
# File lib/openxml/docx/parts/styles.rb, line 19
def to_xml
  build_standalone_xml do |xml|
    xml.styles(root_namespaces) {
      xml.parent.namespace = :w
      add_default_styles(xml)
      styles.each { |style| style.to_xml(xml) }
    }
  end
end

Private Instance Methods

add_default_styles(xml) click to toggle source
# File lib/openxml/docx/parts/styles.rb, line 31
def add_default_styles(xml)
  xml["w"].docDefaults {
    xml["w"].rPrDefault {
      xml["w"].rPr {
        xml["w"].lang("w:bidi" => "ar-SA", "w:eastAsia" => "en-US", "w:val" => "en-US")
      }
    }
    xml["w"].pPrDefault {
      xml["w"].pPr {
        xml["w"].spacing("w:after" => "0", "w:line" => "240", "w:lineRule" => "auto")
      }
    }
  }
end