Class: OoxmlParser::ParagraphProperties

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

Overview

Class for data for ParagraphProperties

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

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

Returns a new instance of ParagraphProperties.



40
41
42
43
44
45
46
47
48
49
# 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

Instance Attribute Details

#alignObject

Returns the value of attribute align.



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

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



34
35
36
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 34

def contextual_spacing
  @contextual_spacing
end

#frame_propertiesFrameProperties (readonly)

Returns frame properties.

Returns:



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

def frame_properties
  @frame_properties
end

#indentObject

Returns the value of attribute indent.



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

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



36
37
38
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 36

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



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

def keep_next
  @keep_next
end

#levelObject

Returns the value of attribute level.



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

def level
  @level
end

#margin_leftObject

Returns the value of attribute margin_left.



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

def margin_left
  @margin_left
end

#margin_rightObject

Returns the value of attribute margin_right.



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

def margin_right
  @margin_right
end

#numberingObject

Returns the value of attribute numbering.



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

def numbering
  @numbering
end

#paragraph_bordersBorders

Returns borders of paragraph.

Returns:

  • (Borders)

    borders of paragraph



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

def paragraph_borders
  @paragraph_borders
end

#paragraph_style_refParagraphStyleRef

Returns Referenced Paragraph Style.

Returns:



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

def paragraph_style_ref
  @paragraph_style_ref
end

#run_propertiesRunProperties

Returns properties of run.

Returns:



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

def run_properties
  @run_properties
end

#section_propertiesPageProperties

Returns properties of section.

Returns:



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

def section_properties
  @section_properties
end

#shadeShade

Returns Shade property.

Returns:

  • (Shade)

    Shade property



38
39
40
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb', line 38

def shade
  @shade
end

#spacingObject

Returns the value of attribute spacing.



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

def spacing
  @spacing
end

#spacing_afterObject

Returns the value of attribute spacing_after.



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

def spacing_after
  @spacing_after
end

#spacing_beforeObject

Returns the value of attribute spacing_before.



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

def spacing_before
  @spacing_before
end

#tabsTabs

Returns list of tabs.

Returns:

  • (Tabs)

    list of tabs



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

def tabs
  @tabs
end

Instance Method Details

#parse(node) ⇒ ParagraphProperties

Parse ParagraphProperties object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# 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