Class: OoxmlParser::RunProperties

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

Overview

Data about ‘rPr` object

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(parent: nil) ⇒ RunProperties

Returns a new instance of RunProperties.



36
37
38
39
40
41
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 36

def initialize(parent: nil)
  @font_name = ''
  @font_style = FontStyle.new
  @baseline = :baseline
  @parent = parent
end

Instance Attribute Details

#baselineObject

Returns the value of attribute baseline.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 11

def baseline
  @baseline
end

#capsObject

Returns the value of attribute caps.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 11

def caps
  @caps
end

#colorRunSpacing

Returns get color.

Returns:



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

def color
  @color
end

#dirtyObject

Returns the value of attribute dirty.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 11

def dirty
  @dirty
end

#embossObject

Returns the value of attribute emboss.



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

def emboss
  @emboss
end

#font_colorObject

Returns the value of attribute font_color.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 11

def font_color
  @font_color
end

#font_nameObject

Returns the value of attribute font_name.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 11

def font_name
  @font_name
end

#font_sizeObject

Returns the value of attribute font_size.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 11

def font_size
  @font_size
end

#font_size_complexFloat

This element specifies the font size which shall be applied to all complex script characters in the contents of this run when displayed

Returns:

  • (Float)


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

def font_size_complex
  @font_size_complex
end

#font_styleObject

Returns the value of attribute font_style.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 11

def font_style
  @font_style
end

Returns the value of attribute hyperlink.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 11

def hyperlink
  @hyperlink
end

#languageLanguage

Returns language property.

Returns:



24
25
26
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 24

def language
  @language
end

#outlineObject

Returns the value of attribute outline.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 11

def outline
  @outline
end

#positionPosition

Returns position property.

Returns:



26
27
28
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 26

def position
  @position
end

#rtlObject

Returns the value of attribute rtl.



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

def rtl
  @rtl
end

#run_styleRunStyle

Returns run style.

Returns:



30
31
32
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 30

def run_style
  @run_style
end

#shadeShade

Returns shade property.

Returns:

  • (Shade)

    shade property



28
29
30
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 28

def shade
  @shade
end

#shadowObject

Returns the value of attribute shadow.



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

def shadow
  @shadow
end

#sizeSize

Returns get run size.

Returns:

  • (Size)

    get run size



18
19
20
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 18

def size
  @size
end

#spaceObject

Returns the value of attribute space.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 11

def space
  @space
end

#spacingRunSpacing

Returns get run spacing.

Returns:



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

def spacing
  @spacing
end

#vanishObject

Returns the value of attribute vanish.



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

def vanish
  @vanish
end

#vertical_alignObject

Returns the value of attribute vertical_align.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 11

def vertical_align
  @vertical_align
end

Instance Method Details

#parse(node) ⇒ RunProperties

Parse RunProperties object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 46

def parse(node)
  @font_style = Presentation.current_font_style.dup
  node.attributes.each do |key, value|
    case key
    when 'sz'
      @font_size = value.value.to_f / 100.0
    when 'szCs'
      @font_size_complex = node.attribute('val').value.to_i / 2.0
    when 'spc'
      @space = OoxmlSize.new(value.value.to_f, :one_100th_point)
    when 'b'
      @font_style.bold = option_enabled?(node, 'b')
    when 'i'
      @font_style.italic = option_enabled?(node, 'i')
    when 'u'
      @font_style.underlined = Underline.new(parent: self).parse(value.value)
    when 'strike'
      @font_style.strike = value_to_symbol(value)
    when 'baseline'
      case value.value.to_i
      when -25_000, -30_000
        @baseline = :subscript
      when 30_000
        @baseline = :superscript
      when 0
        @baseline = :baseline
      end
    when 'cap'
      @caps = value.value.to_sym
    end
  end
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'sz'
      @size = Size.new.parse(node_child)
    when 'shadow'
      @shadow = option_enabled?(node_child)
    when 'emboss'
      @emboss = option_enabled?(node_child)
    when 'vanish'
      @vanish = option_enabled?(node_child)
    when 'rtl'
      @rtl = option_enabled?(node_child)
    when 'spacing'
      @spacing = RunSpacing.new(parent: self).parse(node_child)
    when 'color'
      @color = OoxmlColor.new(parent: self).parse(node_child)
    when 'solidFill'
      @font_color = Color.parse_color(node_child.xpath('*').first)
    when 'latin'
      @font_name = node_child.attribute('typeface').value
    when 'b'
      @font_style.bold = option_enabled?(node_child)
    when 'i'
      @font_style.italic = option_enabled?(node_child, 'i')
    when 'u'
      @font_style.underlined = Underline.new(:single)
    when 'vertAlign'
      @vertical_align = node_child.attribute('val').value.to_sym
    when 'rFont'
      @font_name = node_child.attribute('val').value
    when 'rFonts'
      @font_name = node_child.attribute('ascii').value if node_child.attribute('ascii')
    when 'strike'
      @font_style.strike = option_enabled?(node_child)
    when 'hlinkClick'
      @hyperlink = Hyperlink.new(parent: self).parse(node_child)
    when 'ln'
      @outline = Outline.new(parent: self).parse(node_child)
    when 'lang'
      @language = Language.new(parent: self).parse(node_child)
    when 'position'
      @position = Position.new(parent: self).parse(node_child)
    when 'shd'
      @shade = Shade.new(parent: self).parse(node_child)
    when 'rStyle'
      @run_style = RunStyle.new(parent: self).parse(node_child)
    end
  end
  @font_color = DocxColorScheme.new(parent: self).parse(node)
  @font_name = Presentation.default_font_typeface if @font_name.empty?
  @font_size = Presentation.default_font_size if @font_size.nil?
  self
end