Class: OoxmlParser::ParagraphProperties

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(numbering = NumberingProperties.new, parent: nil) ⇒ ParagraphProperties

Returns a new instance of ParagraphProperties.



31
32
33
34
35
36
37
38
39
40
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 31

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 = []
  @parent = parent
end

Instance Attribute Details

#alignObject

Returns the value of attribute align.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 8

def align
  @align
end

#contextual_spacingTrue, False

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

Returns:

  • (True, False)

    This element specifies that any space specified



27
28
29
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 27

def contextual_spacing
  @contextual_spacing
end

#frame_propertiesFrameProperties (readonly)

Returns frame properties.

Returns:



10
11
12
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 10

def frame_properties
  @frame_properties
end

#indentObject

Returns the value of attribute indent.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 8

def indent
  @indent
end

#justificationSymbol

Returns The alignment or justification to be applied to a paragraph.

Returns:

  • (Symbol)

    The alignment or justification to be applied to a paragraph



29
30
31
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 29

def justification
  @justification
end

#keep_nextTrue, False

(or at least part of it) should be rendered on the same page as the next paragraph when possible

Returns:

  • (True, False)

    Specifies that the paragraph



20
21
22
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 20

def keep_next
  @keep_next
end

#levelObject

Returns the value of attribute level.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 8

def level
  @level
end

#margin_leftObject

Returns the value of attribute margin_left.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 8

def margin_left
  @margin_left
end

#margin_rightObject

Returns the value of attribute margin_right.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 8

def margin_right
  @margin_right
end

#numberingObject

Returns the value of attribute numbering.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 8

def numbering
  @numbering
end

#paragraph_bordersBorders

Returns borders of paragraph.

Returns:

  • (Borders)

    borders of paragraph



16
17
18
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 16

def paragraph_borders
  @paragraph_borders
end

#run_propertiesRunProperties

Returns properties of run.

Returns:



14
15
16
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 14

def run_properties
  @run_properties
end

#section_propertiesPageProperties

Returns properties of section.

Returns:



22
23
24
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 22

def section_properties
  @section_properties
end

#spacingObject

Returns the value of attribute spacing.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 8

def spacing
  @spacing
end

#spacing_afterObject

Returns the value of attribute spacing_after.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 8

def spacing_after
  @spacing_after
end

#spacing_beforeObject

Returns the value of attribute spacing_before.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 8

def spacing_before
  @spacing_before
end

#tabsTabs

Returns list of tabs.

Returns:

  • (Tabs)

    list of tabs



12
13
14
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 12

def tabs
  @tabs
end

Instance Method Details

#parse(node) ⇒ ParagraphProperties

Parse ParagraphProperties object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 45

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 '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'
      @tabs = Tabs.new(parent: self).parse(node_child)
    when '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 'keepNext'
      @keep_next = true
    when 'sectPr'
      @section_properties = PageProperties.new(parent: self).parse(node_child, @parent, DocxParagraphRun.new)
    when 'spacing'
      @spacing = ParagraphSpacing.new(parent: self).parse(node_child)
    when 'jc'
      @justification = value_to_symbol(node_child.attribute('val'))
    when 'contextualSpacing'
      @contextual_spacing = option_enabled?(node_child)
    end
  end
  self
end