class OoxmlParser::ParagraphProperties

Class for data for ParagraphProperties

Attributes

align[RW]
contextual_spacing[RW]

@return [True, False] This element specifies that any space specified before or after this paragraph, specified using the spacing element (17.3.1.33), should not be applied when the preceding and following paragraphs are of the same paragraph style, affecting the top and bottom spacing respectively

frame_properties[R]

@return [FrameProperties] frame properties

indent[RW]
justification[RW]

@return [Symbol] The alignment or justification to be applied to a paragraph

keep_next[RW]

@return [True, False] Specifies that the paragraph (or at least part of it) should be rendered on the same page as the next paragraph when possible

level[RW]
margin_left[RW]
margin_right[RW]
numbering[RW]
paragraph_borders[RW]

@return [Borders] borders of paragraph

paragraph_style_ref[RW]

@return [ParagraphStyleRef] Referenced Paragraph Style

run_properties[RW]

@return [RunProperties] properties of run

section_properties[RW]

@return [PageProperties] properties of section

shade[RW]

@return [Shade] Shade property

spacing[RW]
spacing_after[RW]
spacing_before[RW]
tabs[RW]

@return [Tabs] list of tabs

Public Class Methods

new(numbering = NumberingProperties.new, parent: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb, line 40
def initialize(numbering = NumberingProperties.new, parent: nil)
  @numbering = numbering
  @spacing = Spacing.new(OoxmlSize.new(0),
                         OoxmlSize.new(0),
                         OoxmlSize.new(1, :centimeter),
                         :multiple)
  @keep_next = false
  @tabs = []
  super(parent: parent)
end

Public Instance Methods

parse(node) click to toggle source

Parse ParagraphProperties object @param node [Nokogiri::XML:Element] node to parse @return [ParagraphProperties] result of parsing

# File lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb, line 54
def parse(node)
  @spacing.parse(node)
  node.attributes.each do |key, value|
    case key
    when 'algn'
      @align = value_to_symbol(value)
    when 'lvl'
      @level = value.value.to_i
    when 'indent'
      @indent = OoxmlSize.new(value.value.to_f, :emu)
    when 'marR'
      @margin_right = OoxmlSize.new(value.value.to_f, :emu)
    when 'marL'
      @margin_left = OoxmlSize.new(value.value.to_f, :emu)
    end
  end
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'buSzPct'
      @numbering.size = node_child.attribute('val').value
    when 'buFont'
      @numbering.font = node_child.attribute('typeface').value
    when 'buChar'
      @numbering.symbol = node_child.attribute('char').value
    when 'buBlip'
      @numbering.image = BulletImage.new(parent: self).parse(node_child)
    when 'buAutoNum'
      @numbering.type = node_child.attribute('type').value.to_sym
      @numbering.start_at = node_child.attribute('startAt').value if node_child.attribute('startAt')
    when 'framePr'
      @frame_properties = FrameProperties.new(parent: self).parse(node_child)
    when 'tabs', 'tabLst'
      @tabs = Tabs.new(parent: self).parse(node_child)
    when 'ind'
      @indent = Indents.new(parent: self).parse(node_child)
    when 'rPr'
      @run_properties = RunProperties.new(parent: self).parse(node_child)
    when 'pBdr'
      @paragraph_borders = ParagraphBorders.new(parent: self).parse(node_child)
    when 'pStyle'
      @paragraph_style_ref = ParagraphStyleRef.new(parent: self).parse(node_child)
    when 'keepNext'
      @keep_next = true
    when 'sectPr'
      @section_properties = PageProperties.new(parent: self).parse(node_child, @parent, DocxParagraphRun.new)
    when 'shd'
      @shade = Shade.new(parent: self).parse(node_child)
    when 'spacing'
      @spacing = ParagraphSpacing.new(parent: self).parse(node_child)
    when 'jc'
      @justification_object = ValuedChild.new(:string, parent: self).parse(node_child)
      @justification = value_to_symbol(@justification_object)
    when 'contextualSpacing'
      contextual_spacing_object = ValuedChild.new(:boolean, parent: self).parse(node_child)
      @contextual_spacing = contextual_spacing_object.value
    end
  end
  self
end