Sha256: 65450bda8bf227cfdbb55ebb857ee171f55bf32d62c92417f251f57156abc70d
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
module OpenXml module Docx module Parts class Styles < OpenXml::Part attr_reader :styles def initialize @styles = [] end def <<(style) @styles << style end def to_xml build_standalone_xml do |xml| xml.styles(root_namespaces) { xml.parent.namespace = xml.parent.namespace_definitions.find { |ns| ns.prefix == "w" } add_default_styles(xml) styles.each { |style| style.to_xml(xml) } } end end private 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 def root_namespaces { "xmlns:r" => "http://schemas.openxmlformats.org/officeDocument/2006/relationships", "xmlns:w" => "http://schemas.openxmlformats.org/wordprocessingml/2006/main" } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
openxml-docx-0.9.0 | lib/openxml/docx/parts/styles.rb |
openxml-docx-0.8.0 | lib/openxml/docx/parts/styles.rb |
openxml-docx-0.8.0.beta1 | lib/openxml/docx/parts/styles.rb |