Class: OoxmlParser::RunProperties
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::RunProperties
- Defined in:
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb
Constant Summary
Constants inherited from OOXMLDocumentObject
OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA
Instance Attribute Summary collapse
-
#baseline ⇒ Object
Returns the value of attribute baseline.
-
#caps ⇒ Object
Returns the value of attribute caps.
-
#dirty ⇒ Object
Returns the value of attribute dirty.
-
#font_color ⇒ Object
Returns the value of attribute font_color.
-
#font_name ⇒ Object
Returns the value of attribute font_name.
-
#font_size ⇒ Object
Returns the value of attribute font_size.
-
#font_style ⇒ Object
Returns the value of attribute font_style.
-
#hyperlink ⇒ Object
Returns the value of attribute hyperlink.
-
#outline ⇒ Object
Returns the value of attribute outline.
-
#space ⇒ Object
Returns the value of attribute space.
-
#vertical_align ⇒ Object
Returns the value of attribute vertical_align.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(font_name = '', font_style = FontStyle.new, font_color = nil, space = nil, baseline = :baseline) ⇒ RunProperties
constructor
A new instance of RunProperties.
Methods inherited from OOXMLDocumentObject
#==, add_to_xmls_stack, copy_file_and_rename_to_zip, copy_media_file, current_xml, dir, encrypted_file?, get_link_from_rels, media_folder, option_enabled?, unzip_file
Constructor Details
#initialize(font_name = '', font_style = FontStyle.new, font_color = nil, space = nil, baseline = :baseline) ⇒ RunProperties
Returns a new instance of RunProperties.
8 9 10 11 12 13 14 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 8 def initialize(font_name = '', font_style = FontStyle.new, font_color = nil, space = nil, baseline = :baseline) @font_name = font_name @font_style = font_style @font_color = font_color @space = space @baseline = baseline end |
Instance Attribute Details
#baseline ⇒ Object
Returns the value of attribute baseline.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 5 def baseline @baseline end |
#caps ⇒ Object
Returns the value of attribute caps.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 5 def caps @caps end |
#dirty ⇒ Object
Returns the value of attribute dirty.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 5 def dirty @dirty end |
#font_color ⇒ Object
Returns the value of attribute font_color.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 5 def font_color @font_color end |
#font_name ⇒ Object
Returns the value of attribute font_name.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 5 def font_name @font_name end |
#font_size ⇒ Object
Returns the value of attribute font_size.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 5 def font_size @font_size end |
#font_style ⇒ Object
Returns the value of attribute font_style.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 5 def font_style @font_style end |
#hyperlink ⇒ Object
Returns the value of attribute hyperlink.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 5 def hyperlink @hyperlink end |
#outline ⇒ Object
Returns the value of attribute outline.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 5 def outline @outline end |
#space ⇒ Object
Returns the value of attribute space.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 5 def space @space end |
#vertical_align ⇒ Object
Returns the value of attribute vertical_align.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 5 def vertical_align @vertical_align end |
Class Method Details
.parse(character_props_node) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 16 def self.parse(character_props_node) character_properties = RunProperties.new character_properties.font_style = Presentation.current_font_style.dup character_props_node.attributes.each do |key, value| case key when 'sz' character_properties.font_size = value.value.to_f / 100.0 when 'spc' character_properties.space = (value.value.to_f / 2_834.0).round(2) when 'b' character_properties.font_style.bold = OOXMLDocumentObject.option_enabled?(character_props_node, 'b') when 'i' character_properties.font_style.italic = OOXMLDocumentObject.option_enabled?(character_props_node, 'i') when 'u' character_properties.font_style.underlined = Underline.parse(value.value) when 'strike' character_properties.font_style.strike = Strikeout.parse(value) when 'baseline' case value.value.to_i when -25_000, -30_000 character_properties.baseline = :subscript when 30_000 character_properties.baseline = :superscript when 0 character_properties.baseline = :baseline end when 'cap' character_properties.caps = value.value.to_sym end end character_properties.font_color = DocxColorScheme.parse(character_props_node) character_props_node.xpath('*').each do |properties_element| case properties_element.name when 'solidFill' character_properties.font_color = Color.parse_color(properties_element.xpath('*').first) when 'latin' character_properties.font_name = properties_element.attribute('typeface').value when 'b' character_properties.font_style.bold = OOXMLDocumentObject.option_enabled?(properties_element) when 'i' character_properties.font_style.italic = OOXMLDocumentObject.option_enabled?(properties_element, 'i') when 'u' character_properties.font_style.underlined = Underline.new(:single) when 'vertAlign' character_properties.vertical_align = properties_element.attribute('val').value.to_sym when 'rFont' character_properties.font_name = properties_element.attribute('val').value when 'color' character_properties.font_color = Color.parse_color_tag(properties_element) when 'strike' character_properties.font_style.strike = OOXMLDocumentObject.option_enabled?(properties_element) when 'hlinkClick' character_properties.hyperlink = Hyperlink.parse(properties_element) when 'ln' character_properties.outline = Outline.parse(properties_element) end end character_properties.font_color = DocxColorScheme.parse(character_props_node) character_properties.font_name = Presentation.default_font_typeface if character_properties.font_name.empty? character_properties.font_size = Presentation.default_font_size if character_properties.font_size.nil? character_properties end |