Class: OoxmlParser::DocxParagraphRun
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::DocxParagraphRun
- Includes:
- DocxParagraphRunHelpers
- Defined in:
- lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb
Instance Attribute Summary collapse
-
#alternate_content ⇒ Object
Returns the value of attribute alternate_content.
-
#background_color ⇒ Object
Returns the value of attribute background_color.
-
#break ⇒ Object
Returns the value of attribute break.
-
#caps ⇒ Object
Returns the value of attribute caps.
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#drawings ⇒ Object
Returns the value of attribute drawings.
-
#effect ⇒ Object
Returns the value of attribute effect.
-
#em ⇒ Object
Returns the value of attribute em.
-
#endnote ⇒ Object
Returns the value of attribute endnote.
-
#fld_char ⇒ Object
Returns the value of attribute fld_char.
-
#font ⇒ Object
Returns the value of attribute font.
-
#font_color ⇒ Object
Returns the value of attribute font_color.
-
#font_style ⇒ Object
Returns the value of attribute font_style.
-
#footnote ⇒ Object
Returns the value of attribute footnote.
-
#highlight ⇒ Object
Returns the value of attribute highlight.
- #instruction ⇒ String
-
#link ⇒ Object
Returns the value of attribute link.
-
#number ⇒ Object
Returns the value of attribute number.
-
#object ⇒ RunObject
Object of run.
-
#page_number ⇒ Object
Returns the value of attribute page_number.
-
#position ⇒ Object
Returns the value of attribute position.
-
#run_properties ⇒ RunProperties
Properties of run.
-
#shape ⇒ Object
Returns the value of attribute shape.
-
#size ⇒ Object
Returns the value of attribute size.
-
#spacing ⇒ Object
Returns the value of attribute spacing.
-
#style ⇒ Object
Returns the value of attribute style.
-
#text ⇒ Object
Returns the value of attribute text.
-
#text_fill ⇒ Object
Returns the value of attribute text_fill.
-
#text_outline ⇒ Object
Returns the value of attribute text_outline.
-
#touch ⇒ Object
Returns the value of attribute touch.
-
#vertical_align ⇒ Object
Returns the value of attribute vertical_align.
-
#w ⇒ Object
Returns the value of attribute w.
Attributes inherited from OOXMLDocumentObject
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #drawing ⇒ Object
-
#initialize ⇒ DocxParagraphRun
constructor
A new instance of DocxParagraphRun.
- #initialize_copy(source) ⇒ Object
- #parse(r_tag, char_number, parent: nil) ⇒ Object
Methods included from DocxParagraphRunHelpers
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
Constructor Details
#initialize ⇒ DocxParagraphRun
Returns a new instance of DocxParagraphRun.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 23 def initialize @number = 0 @font = 'Arial' @vertical_align = :baseline @size = 11 @font_color = Color.new @font_style = FontStyle.new @text = '' @drawings = [] @w = false @position = 0.0 @spacing = 0.0 @break = false @comments = [] @page_number = false end |
Instance Attribute Details
#alternate_content ⇒ Object
Returns the value of attribute alternate_content.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def alternate_content @alternate_content end |
#background_color ⇒ Object
Returns the value of attribute background_color.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def background_color @background_color end |
#break ⇒ Object
Returns the value of attribute break.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def break @break end |
#caps ⇒ Object
Returns the value of attribute caps.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def caps @caps end |
#comments ⇒ Object
Returns the value of attribute comments.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def comments @comments end |
#drawings ⇒ Object
Returns the value of attribute drawings.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def drawings @drawings end |
#effect ⇒ Object
Returns the value of attribute effect.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def effect @effect end |
#em ⇒ Object
Returns the value of attribute em.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def em @em end |
#endnote ⇒ Object
Returns the value of attribute endnote.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def endnote @endnote end |
#fld_char ⇒ Object
Returns the value of attribute fld_char.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def fld_char @fld_char end |
#font ⇒ Object
Returns the value of attribute font.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def font @font end |
#font_color ⇒ Object
Returns the value of attribute font_color.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def font_color @font_color end |
#font_style ⇒ Object
Returns the value of attribute font_style.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def font_style @font_style end |
#footnote ⇒ Object
Returns the value of attribute footnote.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def footnote @footnote end |
#highlight ⇒ Object
Returns the value of attribute highlight.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def highlight @highlight end |
#instruction ⇒ String
17 18 19 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 17 def instruction @instruction end |
#link ⇒ Object
Returns the value of attribute link.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def link @link end |
#number ⇒ Object
Returns the value of attribute number.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def number @number end |
#object ⇒ RunObject
Returns object of run.
21 22 23 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 21 def object @object end |
#page_number ⇒ Object
Returns the value of attribute page_number.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def page_number @page_number end |
#position ⇒ Object
Returns the value of attribute position.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def position @position end |
#run_properties ⇒ RunProperties
Returns properties of run.
19 20 21 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 19 def run_properties @run_properties end |
#shape ⇒ Object
Returns the value of attribute shape.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def shape @shape end |
#size ⇒ Object
Returns the value of attribute size.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def size @size end |
#spacing ⇒ Object
Returns the value of attribute spacing.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def spacing @spacing end |
#style ⇒ Object
Returns the value of attribute style.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def style @style end |
#text ⇒ Object
Returns the value of attribute text.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def text @text end |
#text_fill ⇒ Object
Returns the value of attribute text_fill.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def text_fill @text_fill end |
#text_outline ⇒ Object
Returns the value of attribute text_outline.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def text_outline @text_outline end |
#touch ⇒ Object
Returns the value of attribute touch.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def touch @touch end |
#vertical_align ⇒ Object
Returns the value of attribute vertical_align.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def vertical_align @vertical_align end |
#w ⇒ Object
Returns the value of attribute w.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 11 def w @w end |
Class Method Details
.parse_font_by_theme(theme) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 119 def self.parse_font_by_theme(theme) doc = Nokogiri::XML(File.open("#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/theme/theme1.xml")) doc.search('//a:fontScheme').each do |font_scheme| if theme.include?('major') font_scheme.xpath('a:majorFont').each do |major_font| major_font.xpath('a:latin').each do |latin| return latin.attribute('typeface').value end end elsif theme.include?('minor') font_scheme.xpath('a:minorFont').each do |minor_font| minor_font.xpath('a:latin').each do |latin| return latin.attribute('typeface').value end end end end end |
Instance Method Details
#==(other) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 51 def ==(other) ignored_attributes = %i[@number @parent] all_instance_variables = instance_variables significan_attribues = all_instance_variables - ignored_attributes significan_attribues.each do |current_attributes| return false unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes) end true end |
#drawing ⇒ Object
46 47 48 49 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 46 def drawing # TODO: Rewrite all tests without this methos @drawings.empty? ? nil : drawings.first end |
#initialize_copy(source) ⇒ Object
40 41 42 43 44 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 40 def initialize_copy(source) super @drawings = source.drawings.clone @comments = source.comments.clone end |
#parse(r_tag, char_number, parent: nil) ⇒ Object
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 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb', line 61 def parse(r_tag, char_number, parent: nil) @parent = parent r_tag.xpath('*').each do |node_child| case node_child.name when 'rPr' parse_properties(node_child, DocumentStructure.default_run_style) @run_properties = RunProperties.new(parent: self).parse(node_child) when 'instrText' if node_child.text.include?('HYPERLINK') hyperlink = Hyperlink.new(node_child.text.sub('HYPERLINK ', '').split(' \\o ').first, node_child.text.sub('HYPERLINK', '').split(' \\o ').last) @link = hyperlink elsif node_child.text[/PAGE\s+\\\*/] @text = '*PAGE NUMBER*' end when 'fldChar' @fld_char = node_child.attribute('fldCharType').value.to_sym when 't' @text += node_child.text when 'noBreakHyphen' @text += '–' when 'tab' @text += "\t" when 'drawing' @drawings << DocxDrawing.new(parent: self).parse(node_child) when 'AlternateContent' @alternate_content = AlternateContent.new(parent: self).parse(node_child) when 'br' if node_child.attribute('type').nil? @break = :line @text += "\r" else case node_child.attribute('type').value when 'page', 'column' @break = node_child.attribute('type').value.to_sym end end when 'footnoteReference' @footnote = HeaderFooter.new(parent: self).parse(node_child) when 'endnoteReference' @endnote = HeaderFooter.new(parent: self).parse(node_child) when 'pict' node_child.xpath('*').each do |pict_node_child| case pict_node_child.name when 'shape' @shape = Shape.new(parent: self).parse(pict_node_child, :shape) when 'rect' @shape = Shape.new(parent: self).parse(pict_node_child, :rectangle) when 'oval' @shape = Shape.new(parent: self).parse(pict_node_child, :oval) end end when 'object' @object = RunObject.new(parent: self).parse(node_child) end end @number = char_number end |