class Parchment::DOCX::Style

Public Class Methods

new() click to toggle source
# File lib/parchment/formats/docx/style.rb, line 15
def initialize
end
new_default_style(node) click to toggle source

The OfficeOpen format has a spcific docDefaults block which describes the globals for the document. This creates a Style Object from that element.

# File lib/parchment/formats/docx/style.rb, line 32
def self.new_default_style(node)
  style = self.new

  # Right now, only concerned about document global font size.
  #
  # OfficeOpen specifications store the font size as half-points. Meaning if
  # something is at 12 points, it will be 24. We want actual full-point size.
  #
  font_size_tag = node.xpath('//w:docDefaults//w:rPrDefault//w:rPr//w:sz').first
  font_size = font_size_tag ? font_size_tag.attributes['val'].value.to_i / 2 : nil

  style.instance_variable_set('@font_size', font_size)
  return style
end
new_from_node(node) click to toggle source

Creates a new Style from the XML w:style element passed in.

# File lib/parchment/formats/docx/style.rb, line 20
def self.new_from_node(node)
  style = self.new
  @node = node
  instance_variable_set('@family',@node.attributes['type'].value)
  instance_variable_set('@id', @node.attributes['styleId'].value)
  return style
end